Browse Source

remove old sources vdr-plugin-cecremote

master
mango 1 year ago
parent
commit
2fe62efb7c
53 changed files with 0 additions and 6294 deletions
  1. +0
    -11
      v/vdr-plugin-cecremote-1.4.0/.gitignore
  2. +0
    -1
      v/vdr-plugin-cecremote-1.4.0/.pc/.quilt_patches
  3. +0
    -1
      v/vdr-plugin-cecremote-1.4.0/.pc/.quilt_series
  4. +0
    -1
      v/vdr-plugin-cecremote-1.4.0/.pc/.version
  5. +0
    -0
      v/vdr-plugin-cecremote-1.4.0/.pc/applied-patches
  6. +0
    -340
      v/vdr-plugin-cecremote-1.4.0/COPYING
  7. +0
    -111
      v/vdr-plugin-cecremote-1.4.0/HISTORY
  8. +0
    -153
      v/vdr-plugin-cecremote-1.4.0/Makefile
  9. +0
    -334
      v/vdr-plugin-cecremote-1.4.0/README
  10. +0
    -63
      v/vdr-plugin-cecremote-1.4.0/ceccontrol.cc
  11. +0
    -43
      v/vdr-plugin-cecremote-1.4.0/ceccontrol.h
  12. +0
    -53
      v/vdr-plugin-cecremote-1.4.0/ceclog.h
  13. +0
    -78
      v/vdr-plugin-cecremote-1.4.0/cecosd.cc
  14. +0
    -42
      v/vdr-plugin-cecremote-1.4.0/cecosd.h
  15. +0
    -846
      v/vdr-plugin-cecremote-1.4.0/cecremote.cc
  16. +0
    -103
      v/vdr-plugin-cecremote-1.4.0/cecremote.h
  17. +0
    -299
      v/vdr-plugin-cecremote-1.4.0/cecremoteplugin.cc
  18. +0
    -98
      v/vdr-plugin-cecremote-1.4.0/cecremoteplugin.h
  19. +0
    -66
      v/vdr-plugin-cecremote-1.4.0/cmd.cc
  20. +0
    -108
      v/vdr-plugin-cecremote-1.4.0/cmd.h
  21. +0
    -950
      v/vdr-plugin-cecremote-1.4.0/configfileparser.cc
  22. +0
    -271
      v/vdr-plugin-cecremote-1.4.0/configfileparser.h
  23. +0
    -41
      v/vdr-plugin-cecremote-1.4.0/configmenu.cc
  24. +0
    -36
      v/vdr-plugin-cecremote-1.4.0/configmenu.h
  25. +0
    -3
      v/vdr-plugin-cecremote-1.4.0/contrib/20-libcec.rules
  26. BIN
      v/vdr-plugin-cecremote-1.4.0/contrib/blueray.mpg
  27. +0
    -68
      v/vdr-plugin-cecremote-1.4.0/contrib/cecremote.xml
  28. +0
    -211
      v/vdr-plugin-cecremote-1.4.0/contrib/cecremote_example.xml
  29. +0
    -64
      v/vdr-plugin-cecremote-1.4.0/debian/README.Debian
  30. +0
    -230
      v/vdr-plugin-cecremote-1.4.0/debian/changelog
  31. +0
    -1
      v/vdr-plugin-cecremote-1.4.0/debian/compat
  32. +0
    -22
      v/vdr-plugin-cecremote-1.4.0/debian/control
  33. +0
    -340
      v/vdr-plugin-cecremote-1.4.0/debian/copyright
  34. +0
    -2
      v/vdr-plugin-cecremote-1.4.0/debian/docs
  35. +0
    -2
      v/vdr-plugin-cecremote-1.4.0/debian/install
  36. +0
    -1
      v/vdr-plugin-cecremote-1.4.0/debian/links
  37. +0
    -6
      v/vdr-plugin-cecremote-1.4.0/debian/plugin.cecremote.conf
  38. +0
    -24
      v/vdr-plugin-cecremote-1.4.0/debian/rules
  39. +0
    -1
      v/vdr-plugin-cecremote-1.4.0/debian/source/format
  40. +0
    -158
      v/vdr-plugin-cecremote-1.4.0/handleactions.cc
  41. +0
    -380
      v/vdr-plugin-cecremote-1.4.0/keymaps.cc
  42. +0
    -74
      v/vdr-plugin-cecremote-1.4.0/keymaps.h
  43. +0
    -114
      v/vdr-plugin-cecremote-1.4.0/opcodemap.cc
  44. +0
    -36
      v/vdr-plugin-cecremote-1.4.0/opcodemap.h
  45. +0
    -26
      v/vdr-plugin-cecremote-1.4.0/po/de_DE.po
  46. +0
    -90
      v/vdr-plugin-cecremote-1.4.0/rtcwakeup.cc
  47. +0
    -45
      v/vdr-plugin-cecremote-1.4.0/rtcwakeup.h
  48. +0
    -82
      v/vdr-plugin-cecremote-1.4.0/statusmonitor.cc
  49. +0
    -64
      v/vdr-plugin-cecremote-1.4.0/statusmonitor.h
  50. +0
    -103
      v/vdr-plugin-cecremote-1.4.0/stillpicplayer.cc
  51. +0
    -43
      v/vdr-plugin-cecremote-1.4.0/stillpicplayer.h
  52. +0
    -55
      v/vdr-plugin-cecremote-1.4.0/stringtools.h
  53. BIN
      v/vdr-plugin-cecremote_1.4.0.orig.tar.xz

+ 0
- 11
v/vdr-plugin-cecremote-1.4.0/.gitignore View File

@@ -1,11 +0,0 @@
syntax: glob
*~
*.orig
*.o
*.so
vdr-cecremote*.tgz
.dependencies
po/*.mo
po/*.pot
push.sh


+ 0
- 1
v/vdr-plugin-cecremote-1.4.0/.pc/.quilt_patches View File

@@ -1 +0,0 @@
debian/patches

+ 0
- 1
v/vdr-plugin-cecremote-1.4.0/.pc/.quilt_series View File

@@ -1 +0,0 @@
series

+ 0
- 1
v/vdr-plugin-cecremote-1.4.0/.pc/.version View File

@@ -1 +0,0 @@
2

+ 0
- 0
v/vdr-plugin-cecremote-1.4.0/.pc/applied-patches View File


+ 0
- 340
v/vdr-plugin-cecremote-1.4.0/COPYING View File

@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

+ 0
- 111
v/vdr-plugin-cecremote-1.4.0/HISTORY View File

@@ -1,111 +0,0 @@
VDR Plugin 'cecremote' Revision History
---------------------------------------

2014-12-25: Version 0.0.1

- Initial revision.

2015-02-08: Version 0.0.2

- Basic functionality implemented.

2015-02-14: Version 0.0.3

- Remove need of std++11
- When no stillpic tag is available, do not start a player

2015-02-16: Version 0.1.0

- Add basic documentation.
- Add option -x to select a filename for the configuration file.
- Renamed the <stillpic> tag to <player> and add a configuration tag to select
Keys for stopping the player.
2015-02-18: Version 0.1.1

- Bugfix in initialization.
- Modify key map.
- Add svdrp command LIST to list active CEC devices.

2015-02-21: Version 0.2.0

- Switched XML Parser to pugixml (http://pugixml.org/).
- Make key maps configurable.
- SVDRP Command to debug and list keymaps and CEC devices.
- New <combokeytimeoutms> in <global> config to set the libCEC combo key
timeout.
- Add <textviewon> CEC command.

2015-02-28: Version 0.3.0

- Fix an out of bounds write of mCECKeyNames and correct the size of
mDefaultKeyMap, as reported by sirwio.
- Add <cecdevicetype>

2015-03-01: Version 0.4.0

- Add <device> section to specify CEC devices also by a physical address.

2015-03-15: Version 0.5.0

- New tag <onmanualstart> in global section which contains a command list which
is executed if the VDR is started manually (not by timer).
- New command lists <onswitchtotv> <onswitchtoradio> <onswitchtoreplay>
in <global> section.
- Fix some valgrind errors.

2015-03-28: Version 0.6.0

- Install a minimal default configuration.
- Add connect/disconnect of the CEC Adapter via svdrpsend CONN/DISC
commands.
- Add <keymaps> to <global> section to overwrite the default keymap used
for the mapping from CEC to VDR-Keys.

2015-04-03: Version 0.7.0

- Improve plugin shutdown.

2015-04-06: Version 1.0.0

- Improve -c command line option. If started with a slash the config
directory is an absolute path, otherwise it is relative to the
VDRs plugin configuration directory.

2015-04-11: Version 1.1.0

- Compiles with libCEC 3.0.0
- Incorporate a patch from sirwio, to get AN_CHANNELS_LIST key functional.
- Fix crashes on svdrp commands VDRK/CECK if no key map id is used as option.
- Add setup option to hide cecremote menu from vdr main menu.

2015-05-17: Version 1.2.0

- Fix incorrect automatic power on of TV.
- Improve configuration of HDMI-Port.

2015-08-07: Version 1.3.0

- Fix incorrect handling of CEC disconnect, which may cause a crash when the
TV is not physically connected to power.
- Add two new setup options "ShutdownOnStandby" and "PowerOffOnStandby"
to configure the behavior of libCEC in case of power off and standby.

2015-09-19: Version 1.3.1

- Compiles with VDR 2.3.1

2016-04-30: Version 1.4.0

- Remove superfluous call to SetHDMIPort (reported by jack-itb)
- Fix manual/automatic start detection (reported by jack-itb)
- Use c++ namespace for the plugin code and removed cec prefixes for
several files and classes.
- Moved the CEC initialization into worker thread for faster startup.
- Add new config option <onceccommand> which allows to start a menu, stop
a CEC menu with still picture player and executes a command list.
- Added a new detection if the VDR is started via the RTC. The old
detection behaviour can be enabled with the new config option
<rtcdetect>false</rtcdetect> in the <global> section.
- Add a udev rule to the contrib directory which disables ModemManger or
mtp-probe access to the pulse-eight CEC adapter.

+ 0
- 153
v/vdr-plugin-cecremote-1.4.0/Makefile View File

@@ -1,153 +0,0 @@
#
# Makefile for a Video Disk Recorder plugin
#
# $Id$

# The official name of this plugin.
# This name will be used in the '-P...' option of VDR to load the plugin.
# By default the main source file also carries this name.

PLUGIN = cecremote

### The version number of this plugin (taken from the main source file):

VERSION = $(shell grep 'static const char \*VERSION *=' cecremoteplugin.cc | awk '{ print $$6 }' | sed -e 's/[";]//g')

### The directory environment:

# Use package data if installed...otherwise assume we're under the VDR source directory:
PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:../../.." pkg-config --variable=$(1) vdr))
LIBDIR = $(call PKGCFG,libdir)
LOCDIR = $(call PKGCFG,locdir)
PLGCFG = $(call PKGCFG,plgcfg)
CONFDEST = $(call PKGCFG,configdir)/plugins/$(PLUGIN)
CONFFILE = $(CONFDEST)/cecremote.xml
#
TMPDIR ?= /tmp

### The compiler options:

# Check for libcec

ifneq (exists, $(shell pkg-config libcec && echo exists))
$(warning ******************************************************************)
$(warning 'libcec' not detected!)
$(error ******************************************************************)
endif


CFLAGS = $(call PKGCFG,cflags)
CXXFLAGS = $(call PKGCFG,cxxflags)


### The version number of VDR's plugin API:

APIVERSION = $(call PKGCFG,apiversion)

### Allow user defined options to overwrite defaults:

-include $(PLGCFG)

### The name of the distribution archive:

ARCHIVE = $(PLUGIN)-$(VERSION)
PACKAGE = vdr-$(ARCHIVE)

### The name of the shared object file:

SOFILE = libvdr-$(PLUGIN).so

### Includes and Defines (add further entries here):

INCLUDES +=

DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"'

# Uncomment for more debug messages
# DEFINES += -DVERBOSEDEBUG

# Flags for libcec
LIBS += $(shell pkg-config --libs libcec)
CFLAGS += $(shell pkg-config --cflags libcec)
CXXFLAGS += $(shell pkg-config --cflags libcec)

# Flags for pugixml xml parser
LIBS += -lpugixml

### The object files (add further files here):

OBJS = cecremote.o cecremoteplugin.o configmenu.o configfileparser.o \
cecosd.o stillpicplayer.o ceccontrol.o keymaps.o statusmonitor.o \
cmd.o opcodemap.o handleactions.o rtcwakeup.o

### The main target:

all: $(SOFILE) i18n

### Implicit rules:

%.o: %.cc
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<

### Dependencies:

MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies
$(DEPFILE): Makefile
@$(MAKEDEP) $(CXXFLAGS) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.cc) > $@

-include $(DEPFILE)

### Internationalization (I18N):

PODIR = po
I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Npot = $(PODIR)/$(PLUGIN).pot

%.mo: %.po
msgfmt -c -o $@ $<

$(I18Npot): $(wildcard *.cc)
xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='<see README>' -o $@ `ls $^`

%.po: $(I18Npot)
msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $<
@touch $@

$(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo
install -D -m644 $< $@

.PHONY: i18n
i18n: $(I18Nmo) $(I18Npot)

install-i18n: $(I18Nmsgs)

### Targets:

$(SOFILE): $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@

install-lib: $(SOFILE)
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)

install-config:
if ! test -f $(DESTDIR)$(CONFFILE); then \
install --mode=644 -D ./contrib/cecremote.xml $(DESTDIR)$(CONFFILE); \
fi

install: install-lib install-i18n install-config

dist: $(I18Npo) clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@tar czf $(PACKAGE).tgz --exclude=*/push.sh -C $(TMPDIR) $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as $(PACKAGE).tgz

clean:
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
@-rm -f .dependencies

+ 0
- 334
v/vdr-plugin-cecremote-1.4.0/README View File

@@ -1,334 +0,0 @@
This is a "plugin" for the Video Disk Recorder (VDR).

Written by: Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>

Project's homepage: http://www.uli-eckhardt.de/vdr/cec.en.shtml

Latest version available at: http://git.uli-eckhardt.de/

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
See the file COPYING for more information.

Requirements
==============
libCEC V2.2.0
http://libcec.pulse-eight.com/
PugiXML V1.5, XML parser for C++
http://pugixml.org/

For PugiXML on Raspberry Pi see:
http://distribution-us.hexxeh.net/raspbian/archive/raspbian/pool/main/p/pugixml/

Description:
==============

Plugin to receive and send commands via CEC.

Installation:
==============

First get connected device either via the cec-client if the plugin is not
running :
echo "scan" | cec-client -s -d 1

The output should look like:
opening a connection to the CEC adapter...
requesting CEC bus information ...
CEC bus information
===================
device #0: TV
address: 0.0.0.0
active source: no
vendor: Panasonic
osd string: TV
CEC version: 1.4
power status: on
language: ger


device #4: Playback 1
address: 1.0.0.0
active source: no
vendor: Panasonic
osd string: CECTester
CEC version: 1.4
power status: on
language: eng


device #8: Playback 2
address: 2.0.0.0
active source: no
vendor: Samsung
osd string: BD Player
CEC version: 1.4
power status: on
language: ???


On a running VDR with the cecremote plugin running, this information can
be retrieved via:
svdrpsend plug cecremote LSTD

The output should look like:

220 vdr SVDRP VideoDiskRecorder 2.0.7; Sun Mar 1 15:19:31 2015; UTF-8
214-Available CEC Devices:
214- Device 0 path: /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3 port: /dev/ttyACM0 Firmware 0004
214-
214-Active Devices:
214- 0# TV @0000 TV TV Panasonic
214- 3# Tuner 1 @1000 Tuner 1 VDR VDR
214- 4# Playback 1 @1000 VDR VDR VDR
214 8# Playback 2 @2000 BD Player BD Player Samsung
221 vdr closing connection

In the plugin configuration directory create the file cecremote.xml (an example
can be found in the contrib directory) with an device entry for each device
which should be handled by this plugin.

In this example device#8 (osd string=CECTester) is the address of the libCEC
device (VDR).

After the first start of the vdr ensure, that the CEC device is not accessed
by the Modem-Manager or mtp-probe by grep for the device path
(/sys/devices/pci00 ...) in the log.

An example udev rule which can be installed at /etc/udev/rules.d/20-libcec.rules
can be found in the contrib directory. This udev rule disables access of the
ModemManger or mtp-probe to the pulse-eight CEC adapter.

Format of the configuration file :
===================================

The configuration file is in XML format The root element is <config>. Within
this element one <global> child element is used to specify global options
for this plugin and several <menu>, <ceckeymap> and <vdrkeymap> child elements.

* Ceckeymap
====================================
This element contains definitions for mapping a CEC Key to one or more VDR keys.
The <ceckeymap> tag must have the attribute "id" specified. This id is used
later in the <player> section to address this key map.

This tag creates a new key map with a preconfigured map. Elements of this map
can be overwritten with <key> elements.

* Vdrkeymap
====================================
This element contains definitions for mapping a VDR Key to one or more CEC keys.
The <vdrkeymap> tag must have the attribute "id" specified. This id is used
later in the <player> section to address this key map.

This tag creates a new key map with a preconfigured map. Elements of this map
can be overwritten with <key> elements.

* Key
====================================
This element is used within <ceckeymap> or <vdrkeymap> to overwrite existing
map entries. The <key> tag must have the attribute "code" specified. This
specifies the key code to redefine. If used in <ceckeymap> code
is a CEC key name (see svdrpsend plug cecremote LSTK for the name of the
supported CEC key codes). When used in <vdrkeymap> the code is the vdr
key name as used for example in keymacros.conf.

The <key> element can have <value> elements which specifies the key codes
to map. If no <value> element is specified, this key code is not mapped and
so this key is not usable.

* Value
====================================
This element is used within <key> to assign key codes to the key map.

If the <value> element is used in <vdrkeymap> the <value> element contains
a CEC key name (see svdrpsend plug cecremote LSTK for the name of the
supported CEC key codes). When used in <ceckeymap> the <value> element is the
vdr key name as used for example in keymacros.conf.

The following example create a new key map with id "TV" where the VDR key OK
is mapped the the CEC "ROOT_MENU" key:

<vdrkeymap id="TV">
<key code="OK">
<value>ROOT_MENU</value>
</key>
</vdrkeymap>

The next example creates an other key map with id "TV". If the CEC key code
"SELECT" is received, this key is mapped to the VDR menu key. The key code
"RIGHT_UP" is mapped to only "right" and not as default to right+up.

<ceckeymap id="TV">
<key code="SELECT">
<value>Menu</value>
</key>
<key code="RIGHT_UP">
<value>Right</value>
</key>
</ceckeymap>


* device
====================================
The device element contains definitions for CEC devices. The main purpose is
to specify a CEC device by the physical address, e.g. when more than one
recording device may be available.

The following configuration would create an entry for a blueray player.
<device id="blueray">
<physical>2000</physical>
<logical>8</logical>
</device>

The software first tries to get the logical address by the device located at
the physical address 2000 (second HDMI port connected to the TV, for the
address concept see for example
http://elinux.org/CEC_%28Consumer_Electronics_Control%29_over_HDMI ).

In case that there is more than one device available at the physical address or
no device could be found on the physical address the logical address (in this
case Playback 2) is used.

* Global
====================================

The child elements of <global> are <rtcdetect>, <cecdebug>, <onstart>,
<onmanualstart>, <onstop> <onswitchtotv>, <onswitchtoradio>, <onswitchtoreplay>
<shutdownonstandby>, <poweroffonstandby> and <keymaps>.

<cecdebug> Debug level for CEC debugging (see cec_log_level in cectypes.h)
<onstart> A command list which is executed upon plugin start.
<onmanualstart> A command list which is executed upon manual plugin start, but
not if the VDR was started due to a timer.
<onstop> A command list which is executed upon plugin shutdown.
<onswitchtotv> A command list which is executed if switched to a TV program.
<onswitchtoradio> A command list which is executed if switched to a radio program.
<onswitchtoreplay> A command list which is executed if the VDR replays a recording.
<keymaps> The <keymaps> tag has the attribute cec, which addresses the
id specified within a <ceckeymap>. This keymap is used to
convert a CEC-Keycode to a VDR-Key.
<cecdevicetype> The device types to register with libCEC. The following
device types are available:
* RECORDING_DEVICE
* TUNER
* TV
* PLAYBACK_DEVICE
* AUDIO_SYSTEM
<hdmiport> Specify the HDMI-Port where the adapter is connected to.
<rtcdetect> If set to true (default) use the rtc driver to detect if
the vdr was started manually or by rtc alarm. Otherwise
use a heuristic. If the VDR was started in a time range
5 minutes before or after an timer was running, the VDR
start is detected as timed start.
<shutdownonstandby> If set to true, all CEC devices are set to standby when the
VDR is shut down. Default is false.
<poweroffonstandby> If set to true, all CEC devices are set to power off when
the VDR is shut down. Default is false.

NOTE: There seems to be a bug in the libCEC implementation for the Raspberry PI
which causes a crash when registering more than one device type.

For the description of a command list see below.

* Menu
====================================

Defines a menu for executing CEC and shell commands.

The <menu> tag must have the following attributes:
* name : The name of the menu (displayed in the OSD)
* address : CEC device address.
The child elements of <menu> are <onstart>, <onstop>, <player>,
<onpoweron>, <onpoweroff>. <onstart>, <onstop> and <onpoweron>, <onpoweroff>
are mutually exclusive.

<player> : (see below).
<onstart> : A command list which is executed when the menu entry is selected.
<onstop> : A command list which is executed if <stillpic> is present and
the player is stopped.
<onpoweron> : A command list which is executed if the device is currently
powered off.
<onpoweroff>: A command list which is executed if the device is currently
powered on.

* OnCECCommand
====================================

Perform actions when a cec command is received.

The <onceccommand> must have the following attributes:
* command : A CEC opcode as string as defined in cectypes.h, but without the
CEC_OPCODE_ prefix. The opcode can also be defined as a numeric or
hex value. The following examples are valid defines for
CEC_OPCODE_STANDBY:
command="STANDBY", command="0x36", command="54"
* initiator : The device which initiated this command.
The child elements of <onceccommand> are <stopmenu>, <execmenu> and
<commandlist>.

<stopmenu>menu name</stopmenu>:
If a menu with the name has a still pic player, this player is stopped.
<execmenu>menu name</execmenu>:
Execute the CEC plugin menu entry with the name.
<commandlist>:
A command list which is executed when this command is received.

* Player
====================================
Starts a stillpic player and waits until the player is stopped. This tag can
not be used with <onpoweron> and <onpoweroff>.

The <player> tag must have the following attribute:
* file : Filename of the still-picture in mpeg format.
The child elements of <player> are <stop>.and <keymaps>

<stop> : Can be used several times and contains a VDR-Key to stop this player.
<keymaps> : The <keymaps> tag has the attributes "cec" and "vdr" which
addresses the id specified within <ceckeymap> or <vdrkeymap>.
When the player is started, these keymaps are activated. If a tag is
missing, the default keymap is used.

* Command lists
====================================

A command list defines a list of actions to be executed.

The child elements of a command list are <poweron>, <poweroff>, <makeactive>
and <exec>.

<poweron>CEC Device Address</poweron> : Powers the device on.
<poweroff>CEC Device Address</poweroff> : Powers the device off.
<makeactive/> : Makes the VDR the active device.
<makeinactive/> : Remove the VDR as the active device.
<textviewon>CEC Device Address</textviewon> : Send the TextViewOn CEC command to
the CEC device.
<exec>Command</exec> : Executes a shell command.


* SVDRP Commands
=====================================
LSTK : List all supported CEC keycodes
LSTD : List active CEC devices
KEYM : List available key maps
VDRK [id]: Display the VDR->CEC key map with the given id
CECK [id]: Display the CEC->VDR key map with the given id
CONN : Connect the CEC adapter.
DISC : Disconnect the CEC adapter. This can be used for example,
if an other program requires access to the CEC adapter.

* Commandline arguments
=====================================
-c --configdir <dir> : Directory for the configuration file. If the directory
does not start with a slash, the directory is relative
to the vdr config directory, otherwise it specifies an
absolute path. Default is cecremote.
-x --configfile <file> : Name of the configuartion file. Default is cecremote.xml

+ 0
- 63
v/vdr-plugin-cecremote-1.4.0/ceccontrol.cc View File

@@ -1,63 +0,0 @@
/*
* CECRemote PlugIn for VDR
*
* Copyright (C) 2014, 2015 Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* This class implements the VDR cControl for the cec player
*
*/

#include "ceccontrol.h"
#include "stillpicplayer.h"
#include "ceclog.h"

namespace cecplugin {

cCECControl::cCECControl(const cCECMenu &menuitem, cPluginCecremote *plugin) :
cControl(mStillPicPlayer = new cStillPicPlayer(menuitem))
{
mPlugin = plugin;
mMenuItem = menuitem;
mPlugin->mKeyMaps.SetActiveKeymaps(menuitem.mVDRKeymap, menuitem.mCECKeymap);
mPlugin->PushCmdQueue(mMenuItem.mOnStart);
}

cCECControl::~cCECControl() {
mPlugin->PushCmdQueue(mMenuItem.mOnStop);
mPlugin->SetDefaultKeymaps();
delete mStillPicPlayer;
}

void cCECControl::Hide(void)
{
Dsyslog("Hide cCECControl");
}

/*
* Get VDR keys and queue them to send to the active CEC device.
*/
eOSState cCECControl::ProcessKey(eKeys key)
{
cKey k;
if (key != kNone) Dsyslog("cCECControl ProcessKey %d %s", key, k.ToString(key,false));

if (mMenuItem.isStopKey(key)) {
Hide();
return osEnd;
}
if (key == kNone) {
return osContinue;
}

key = (eKeys)((int)key & ~k_Repeat);
cCmd cmd(CEC_VDRKEYPRESS, (int)key, &mMenuItem.mDevice);
mPlugin->PushCmd(cmd);

return (osContinue);
}

} // namespace cecplugin


+ 0
- 43
v/vdr-plugin-cecremote-1.4.0/ceccontrol.h View File

@@ -1,43 +0,0 @@
/*
* CECRemote PlugIn for VDR
*
* Copyright (C) 2014-2016 Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* This class implements the VDR cControl for the cec player
*
*/

#ifndef CECONTROL_H_
#define CECONTROL_H_

#include <vdr/player.h>

#include "cecremoteplugin.h"
#include "stillpicplayer.h"

namespace cecplugin {

class cCECControl: public cControl {
private:
cStillPicPlayer *mStillPicPlayer;
cPluginCecremote *mPlugin;
cCECMenu mMenuItem;

public:
cCECControl(const cCECMenu &menuitem, cPluginCecremote *plugin);
virtual ~cCECControl();

virtual void Hide(void);
virtual cOsdObject *GetInfo(void) { return NULL; }
virtual eOSState ProcessKey(eKeys Key);
std::string getMenuTitle() {
return mMenuItem.mMenuTitle;
}
};

} // namespace cecplugin

#endif /* CECONTROL_H_ */

+ 0
- 53
v/vdr-plugin-cecremote-1.4.0/ceclog.h View File

@@ -1,53 +0,0 @@
/*
* CECRemote PlugIn for VDR
*
* Copyright (C) 2014, 2015 Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* This class implements logging functions
*
*/

#ifndef CECLOG_H_
#define CECLOG_H_

namespace cecplugin {

#define MAXSYSLOGBUF 256

static void ceclogmsg (int severity, const char *format, ...)
{
if (SysLogLevel > severity) {
char fmt[MAXSYSLOGBUF];

int facility_priority = LOG_ERR;
if (severity == 1) {
facility_priority = LOG_WARNING;
}
else if (severity == 2) {
facility_priority = LOG_DEBUG;
}

snprintf(fmt, sizeof(fmt), "[cecremote] %s", format);
va_list ap;
va_start(ap, format);
vsyslog(facility_priority ,fmt, ap);
va_end(ap);
}
}

#define Esyslog(a...) ceclogmsg(0, a)
#define Isyslog(a...) ceclogmsg(1, a)
#define Dsyslog(a...) ceclogmsg(2, a)

#ifdef VERBOSEDEBUG
#define Csyslog(a...) ceclogmsg(2, a)
#else
#define Csyslog(a...)
#endif

} // namespace cecplugin

#endif /* CECLOG_H_ */

+ 0
- 78
v/vdr-plugin-cecremote-1.4.0/cecosd.cc View File

@@ -1,78 +0,0 @@
/*
* CECRemote PlugIn for VDR
*
* Copyright (C) 2015 Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* This class implements the OSD menu.
*/

#include <algorithm>
#include <stdexcept>
#include "cecremoteplugin.h"
#include "cecosd.h"
#include "ceclog.h"

using namespace std;
using namespace cecplugin;

namespace cecplugin {

std::vector<cCECMenu> cCECOsd::mMenuItems;

cCECOsd::cCECOsd(cPluginCecremote *plugin) :
cOsdMenu(tr("CEC Device")) {

int cnt = 1;
char num[4];
cCECMenu menuitem;
string menutxt;
cCECMenuList *menulist = plugin->GetMenuList();

for (cCECMenuListIterator i = menulist->begin();
i != menulist->end(); i++) {
menuitem = *i;
if (cnt <= 9) {
sprintf(num,"%d ", cnt);
}
else {
strcpy (num, " ");
}

menutxt = num + menuitem.mMenuTitle;
Add(new cCECOsdItem(menuitem, menutxt.c_str(), plugin));
mMenuItems.push_back(menuitem);
cnt++;
}
}

cCECOsdItem::cCECOsdItem(const cCECMenu &menuitem, const char *menutxt,
cPluginCecremote *plugin) :
cOsdItem(menutxt), mControl(NULL) {
mMenuItem = menuitem;
mPlugin = plugin;
Dsyslog("Menu %s", menutxt);
}

eOSState cCECOsdItem::ProcessKey(eKeys key) {
eOSState state = osUnknown;

if (key == kOk) {
mPlugin->StartPlayer(mMenuItem);
return osEnd;
}
if ((key > k0) && (key <= k9)) {
try {
mPlugin->StartPlayer(cCECOsd::mMenuItems.at(key-k1));
state = osEnd;
} catch (const std::out_of_range &oor) {
Isyslog("StartPlayer Out of range");
}
}
return state;
}

} // namespace cecplugin


+ 0
- 42
v/vdr-plugin-cecremote-1.4.0/cecosd.h View File

@@ -1,42 +0,0 @@
/*
* CECRemote PlugIn for VDR
*
* Copyright (C) 2015 Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* This class implements the OSD menu.
*/

#ifndef CECOSD_H_
#define CECOSD_H_

#include <vdr/menu.h>
#include <vdr/plugin.h>
#include "ceccontrol.h"

namespace cecplugin {

class cCECOsd : public cOsdMenu {
public:
static std::vector<cCECMenu> mMenuItems;
cCECOsd(cPluginCecremote *plugin);
virtual ~cCECOsd() {}
};

class cCECOsdItem : public cOsdItem {
private:
cCECControl *mControl;
cPluginCecremote *mPlugin;
cCECMenu mMenuItem;

public:
cCECOsdItem(const cCECMenu &menuitem, const char *menutxt, cPluginCecremote *plugin);
~cCECOsdItem() {}
virtual eOSState ProcessKey(eKeys key);
};

} // namespace cecplugin

#endif /* CECOSD_H_ */

+ 0
- 846
v/vdr-plugin-cecremote-1.4.0/cecremote.cc View File

@@ -1,846 +0,0 @@
/*
* CECRemote PlugIn for VDR
*
* Copyright (C) 2015-2016 Ulrich Eckhardt <uli-vdr@uli-eckhardt.de>
*
* This code is distributed under the terms and conditions of the
* GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
*
* This class implements the remote receiving and processing the CEC commands.
*/

#include "cecremote.h"
#include "ceclog.h"
#include "cecremoteplugin.h"
#include <sys/wait.h>
// We need this for cecloader.h
#include <iostream>
using namespace std;
#include <cecloader.h>

using namespace cecplugin;

namespace cecplugin {
const char *cCECRemote::VDRNAME = "VDR";
/*
* Callback when libCEC receives a key press
*/
static int CecKeyPressCallback(void *cbParam, const cec_keypress key)
{
static cec_user_control_code lastkey = CEC_USER_CONTROL_CODE_UNKNOWN;
cCECRemote *rem = (cCECRemote *)cbParam;

Dsyslog("key pressed %02x (%d)", key.keycode, key.duration);
if (
((key.keycode >= 0) && (key.keycode <= CEC_USER_CONTROL_CODE_MAX)) &&
((key.duration == 0) || (key.keycode != lastkey))
)
{
lastkey = key.keycode;
cCmd cmd(CEC_KEYRPRESS, (int)key.keycode);
rem->PushCmd(cmd);
}
return 0;
}

/*
* Callback function for libCEC command messages.
* Currently only used for debugging.
*/
static int CecCommandCallback(void *cbParam, const cec_command command)
{
cCECRemote *rem = (cCECRemote *)cbParam;
Dsyslog("CEC Command %d : %s Init %d Dest %d", command.opcode,
rem->mCECAdapter->ToString(command.opcode),
command.initiator, command.destination);
cCmd cmd(CEC_COMMAND, command.opcode, command.initiator);
rem->PushCmd(cmd);

return 0;
}


/*
* Callback function for libCEC alert messages.
* Currently only used for debugging.
*/
static int CecAlertCallback(void *cbParam, const libcec_alert type,
const libcec_parameter param)
{
cCECRemote *rem = (cCECRemote *)cbParam;
Dsyslog("CecAlert %d", type);
switch (type)
{
case CEC_ALERT_CONNECTION_LOST:
Esyslog("Connection lost");
rem->Reconnect();
break;
case CEC_ALERT_TV_POLL_FAILED:
Isyslog("TV Poll failed");
break;
case CEC_ALERT_SERVICE_DEVICE:
Isyslog("CEC_ALERT_SERVICE_DEVICE");
break;
case CEC_ALERT_PERMISSION_ERROR:
Isyslog("CEC_ALERT_PERMISSION_ERROR");
break;
case CEC_ALERT_PORT_BUSY:
Isyslog("CEC_ALERT_PORT_BUSY");
break;
case CEC_ALERT_PHYSICAL_ADDRESS_ERROR:
Isyslog("CEC_ALERT_PHYSICAL_ADDRESS_ERROR");
break;
default:
break;
}
return 0;
}

/*
* Callback function for libCEC to print out log messages.
*/
static int CecLogMessageCallback(void *cbParam, const cec_log_message message)
{
cCECRemote *rem = (cCECRemote *)cbParam;
if ((message.level & rem->getCECLogLevel()) == message.level)
{
string strLevel;
switch (message.level)
{
case CEC_LOG_ERROR:
strLevel = "ERROR: ";
break;
case CEC_LOG_WARNING:
strLevel = "WARNING: ";
break;
case CEC_LOG_NOTICE:
strLevel = "NOTICE: ";
break;
case CEC_LOG_TRAFFIC:
strLevel = "TRAFFIC: ";
break;
case CEC_LOG_DEBUG:
strLevel = "DEBUG: ";
break;
default:
break;
}

char strFullLog[1040];
snprintf(strFullLog, 1039, "CEC %s %s", strLevel.c_str(), message.message);
if (message.level == CEC_LOG_ERROR)
{
Esyslog(strFullLog);
}
else
{
Dsyslog(strFullLog);
}
}
return 0;
}

/*
* Callback function for libCEC when a device gets activated.
* Currently only used for debugging.
*/
static void CECSourceActivatedCallback (void *cbParam,
const cec_logical_address address,
const uint8_t activated)
{
Csyslog("CECSourceActivatedCallback adress %d activated %d", address, activated);
}

/*
* Callback function for libCEC when configuration changes.
* Currently only used for debugging.
*/
static int CECConfigurationCallback (void *cbParam,
const libcec_configuration config)
{
Csyslog("CECConfiguration");
return CEC_TRUE;
}

/*
* Worker thread which processes the command queue and executes the
* received commands.
*/
void cCECRemote::Action(void)
{
cCmd cmd;
cCECList ceckmap;
cec_logical_address addr;
eKeys k;

Connect();

Dsyslog("cCECRemote start worker thread");
while (Running()) {
cmd = WaitCmd();
Dsyslog ("(%d) Action %d Val %d Phys Addr %d Logical %04x %04x Op %d",
cmd.mSerial,
cmd.mCmd, cmd.mVal, cmd.mDevice.mPhysicalAddress,
cmd.mDevice.mLogicalAddressDefined,
cmd.mDevice.mLogicalAddressUsed,
cmd.mCecOpcode);
switch (cmd.mCmd)
{
case CEC_KEYRPRESS:
if ((cmd.mVal >= 0) && (cmd.mVal <= CEC_USER_CONTROL_CODE_MAX)) {
const cKeyList &inputKeys =
mPlugin->mKeyMaps.CECtoVDRKey((cec_user_control_code)cmd.mVal);
cKeyListIterator ikeys;
for (ikeys = inputKeys.begin(); ikeys != inputKeys.end(); ++ikeys) {
k = *ikeys;
Put(k);
Dsyslog (" Put(%d)", k);
}
}
break;
case CEC_POWERON:
if (mCECAdapter != NULL) {
Dsyslog("Power on");
addr = getLogical(cmd.mDevice);
if ((addr != CECDEVICE_UNKNOWN) &&
(!mCECAdapter->PowerOnDevices(addr))) {
Esyslog("PowerOnDevice failed for %s",
mCECAdapter->ToString(addr));
}
else {
WaitForPowerStatus(addr, CEC_POWER_STATUS_ON);
}
}
else {
Esyslog("PowerOnDevice ignored");
}
break;
case CEC_POWEROFF:
if (mCECAdapter != NULL) {
addr = getLogical(cmd.mDevice);
if ((addr != CECDEVICE_UNKNOWN) &&
(!mCECAdapter->StandbyDevices(addr))) {
Esyslog("StandbyDevices failed for %s",
mCECAdapter->ToString(addr));
}
else {
WaitForPowerStatus(addr, CEC_POWER_STATUS_STANDBY);
}
}
else {
Esyslog("StandbyDevices ignored");
}
break;
case CEC_TEXTVIEWON:
if (mCECAdapter != NULL) {
Dsyslog("Textviewon");
addr = getLogical(cmd.mDevice);
if ((addr != CECDEVICE_UNKNOWN) &&
(TextViewOn(addr) != 0)) {
Esyslog("TextViewOn failed for %s",
mCECAdapter->ToString(addr));
}
}
else {
Esyslog("Textviewon ignored");
}
break;
case CEC_MAKEACTIVE:
if (mCECAdapter != NULL) {
Dsyslog ("Make active");
if (!mCECAdapter->SetActiveSource()) {
Esyslog("SetActiveSource failed");
}
}
else {
Esyslog("SetActiveSource ignored");
}
break;
case CEC_MAKEINACTIVE:
if (mCECAdapter != NULL) {
Dsyslog ("Make inactive");
if (!mCECAdapter->SetInactiveView()) {
Esyslog("SetInactiveView failed");
}
}
else {
Esyslog("SetInactiveView ignored");
}
break;
case CEC_VDRKEYPRESS:
if (mCECAdapter != NULL) {
ActionKeyPress(cmd);
}
else {
Esyslog("Keypress ignored");
}
break;
case CEC_EXECSHELL:
Dsyslog ("Exec: %s", cmd.mExec.c_str());
Exec(cmd);
break;
case CEC_EXIT:
Dsyslog("cCECRemote exit worker thread");
Cancel(0);
break;
case CEC_RECONNECT:
Dsyslog("cCECRemote reconnect");
Disconnect();
sleep(1);
Connect();
break;
case CEC_CONNECT:
Dsyslog("cCECRemote connect");
Connect();
break;
case CEC_DISCONNECT:
Dsyslog("cCECRemote disconnect");
Disconnect();
break;
case CEC_COMMAND:
Dsyslog("cCECRemote command %d", cmd.mCecOpcode);
CECCommand(cmd);
break;
case CEC_EXECTOGGLE:
Dsyslog("cCECRemote exec_toggle");
ExecToggle(cmd.mDevice, cmd.mPoweron, cmd.mPoweroff);
break;
default:
Esyslog("Unknown action %d Val %d", cmd.mCmd, cmd.mVal);
break;
}
Csyslog ("(%d) Action finished", cmd.mSerial);
if (cmd.mSerial != -1) {
mProcessedSerial = cmd.mSerial;
mCmdReady.Signal();
}
}
Dsyslog("cCECRemote stop worker thread");
}

/*
* CEC remote constructor.
* Initializes libCEC and the connected CEC adaptor.
*/

cCECRemote::cCECRemote(const cCECGlobalOptions &options, cPluginCecremote *plugin):
cRemote("CEC"),
cThread("CEC receiver"),
mProcessedSerial(-1),
mDevicesFound(0),
mInExec(false)
{
mPlugin = plugin;
mCECAdapter = NULL;
mHDMIPort = options.mHDMIPort;
mBaseDevice = options.mBaseDevice;
mCECLogLevel = options.cec_debug;
mOnStart = options.mOnStart;
mOnStop = options.mOnStop;
mOnManualStart = options.mOnManualStart;
mComboKeyTimeoutMs = options.mComboKeyTimeoutMs;
mDeviceTypes = options.mDeviceTypes;
mShutdownOnStandby = options.mShutdownOnStandby;
mPowerOffOnStandby = options.mPowerOffOnStandby;

SetDescription("CEC Action Thread");

Start();

Csyslog("cCECRemote Init");
}

void cCECRemote::Startup()
{
Csyslog("cCECRemote Startup");

if (mPlugin->GetStartManually()) {
PushCmdQueue(mOnManualStart);
}
PushCmdQueue(mOnStart);
}

void cCECRemote::Connect()
{
Dsyslog("cCECRemote::Connect");
if (mCECAdapter != NULL) {
return;
}
// Initialize Callbacks
mCECCallbacks.Clear();
mCECCallbacks.CBCecLogMessage = &::CecLogMessageCallback;
mCECCallbacks.CBCecKeyPress = &::CecKeyPressCallback;
mCECCallbacks.CBCecCommand = &::CecCommandCallback;
mCECCallbacks.CBCecAlert = &::CecAlertCallback;
mCECCallbacks.CBCecSourceActivated = &::CECSourceActivatedCallback;
mCECCallbacks.CBCecConfigurationChanged = &::CECConfigurationCallback;

// Setup CEC configuration
mCECConfig.Clear();
strncpy(mCECConfig.strDeviceName, VDRNAME, sizeof(mCECConfig.strDeviceName));

// LibCEC before 3.0.0
#ifdef CEC_CLIENT_VERSION_CURRENT
mCECConfig.clientVersion = CEC_CLIENT_VERSION_CURRENT;
#else
// LibCEC 3.0.0
mCECConfig.clientVersion = LIBCEC_VERSION_CURRENT;
#endif
mCECConfig.bActivateSource = CEC_FALSE;
mCECConfig.iComboKeyTimeoutMs = mComboKeyTimeoutMs;
mCECConfig.iHDMIPort = mHDMIPort;
mCECConfig.wakeDevices.Clear();
mCECConfig.powerOffDevices.Clear();
mCECConfig.bShutdownOnStandby = mShutdownOnStandby;
mCECConfig.bPowerOffOnStandby = mPowerOffOnStandby;
mCECConfig.baseDevice = mBaseDevice;
// If no <cecdevicetype> is specified in the <global>, set default
if (mDeviceTypes.empty())
{
mCECConfig.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
}
else {
// Add all device types as specified in <cecdevicetype>
deviceTypeListIterator idev;
for (idev = mDeviceTypes.begin();
idev != mDeviceTypes.end(); ++idev) {
cec_device_type t = *idev;
mCECConfig.deviceTypes.Add(t);
Dsyslog (" Add device %d", t);
}
}

// Setup callbacks
mCECConfig.callbackParam = this;
mCECConfig.callbacks = &mCECCallbacks;
// Initialize libcec
mCECAdapter = LibCecInitialise(&mCECConfig);
if (mCECAdapter == NULL) {
Esyslog("Can not initialize libcec");
return;
}
// init video on targets that need this
mCECAdapter->InitVideoStandalone();
Dsyslog("LibCEC %s", mCECAdapter->GetLibInfo());

mDevicesFound = mCECAdapter->DetectAdapters(mCECAdapterDescription,
MAX_CEC_ADAPTERS, NULL);
if (mDevicesFound <= 0)
{
Esyslog("No adapter found");
UnloadLibCec(mCECAdapter);
mCECAdapter = NULL;
return;
}

for (int i = 0; i < mDevicesFound; i++)
{
Dsyslog("Device %d path: %s port: %s Firmware %04d", i,
mCECAdapterDescription[0].strComPath,
mCECAdapterDescription[0].strComName,
mCECAdapterDescription[0].iFirmwareVersion);
}

if (!mCECAdapter->Open(mCECAdapterDescription[0].strComName))
{
Esyslog("unable to open the device on port %s",
mCECAdapterDescription[0].strComName);
UnloadLibCec(mCECAdapter);
mCECAdapter = NULL;
return;
}

cec_logical_addresses devices = mCECAdapter->GetActiveDevices();
for (int j = 0; j < 16; j++)
{
if (devices[j])
{
cec_logical_address logical_addres = (cec_logical_address) j;

uint16_t phaddr = mCECAdapter->GetDevicePhysicalAddress(logical_addres);
cec_osd_name name = mCECAdapter->GetDeviceOSDName(logical_addres);
cec_vendor_id vendor = (cec_vendor_id)mCECAdapter->GetDeviceVendorId(logical_addres);
Dsyslog(" %15.15s %d@%04x %15.15s %15.15s",
mCECAdapter->ToString(logical_addres),
logical_addres, phaddr, name.name,
mCECAdapter->ToString(vendor));
}
}
Csyslog("END cCECRemote::Initialize");
}

void cCECRemote::Disconnect()
{
if (mCECAdapter != NULL) {
mCECAdapter->SetInactiveView();
mCECAdapter->Close();
UnloadLibCec(mCECAdapter);
}
mCECAdapter = NULL;
Dsyslog("cCECRemote::Disconnect");
}

void cCECRemote::Stop()
{
Dsyslog("Executing onStop");
PushCmdQueue(mOnStop);
// Send exit command to worker thread
cCmd cmd(CEC_EXIT);
PushWaitCmd(cmd);
Csyslog("onStop OK");
}
/*
* Destructor stops the worker thread and unloads libCEC.
*/
cCECRemote::~cCECRemote()
{
Cancel(3);
Disconnect();
}

/*
* Function to list all active CEC devices.
*/
cString cCECRemote::ListDevices()
{
cString s = "Available CEC Devices:";
uint16_t phaddr;
cec_osd_name name;
cec_vendor_id vendor;
cec_power_status powerstatus;

if (mCECAdapter == NULL) {
Esyslog ("ListDevices CEC Adapter disconnected");
s = "CEC Adapter disconnected";
return s;
}

for (int i = 0; i < mDevicesFound; i++)
{
s = cString::sprintf("%s\n Device %d path: %s port: %s Firmware %04d",
*s, i,
mCECAdapterDescription[0].strComPath,
mCECAdapterDescription[0].strComName,
mCECAdapterDescription[0].iFirmwareVersion);
}

s = cString::sprintf("%s\n\nActive Devices:", *s);
cec_logical_addresses devices = mCECAdapter->GetActiveDevices();
cec_logical_addresses own = mCECAdapter->GetLogicalAddresses();

for (int j = 0; j < 16; j++)
{
if (devices[j])
{
cec_logical_address logical_addres = (cec_logical_address)j;

phaddr = mCECAdapter->GetDevicePhysicalAddress(logical_addres);
name = mCECAdapter->GetDeviceOSDName(logical_addres);
vendor = (cec_vendor_id)mCECAdapter->GetDeviceVendorId(logical_addres);

if (own[j]) {
s = cString::sprintf("%s\n %d# %-15.15s@%04x %-15.15s %-14.14s %-15.15s", *s,
logical_addres,
mCECAdapter->ToString(logical_addres),
phaddr, name.name,
VDRNAME, VDRNAME);
}
else {
powerstatus = mCECAdapter->GetDevicePowerStatus(logical_addres);
s = cString::sprintf("%s\n %d# %-15.15s@%04x %-15.15s %-14.14s %-15.15s %-15.15s", *s,
logical_addres,
mCECAdapter->ToString(logical_addres),
phaddr, name.name,
mCECAdapter->GetDeviceOSDName(logical_addres).name,
mCECAdapter->ToString(vendor),
mCECAdapter->ToString(powerstatus));
}
}
}
return s;
}


/*
* Try to get the logical address for a device. If specified, try to use
* the physical address,
*/
cec_logical_address cCECRemote::getLogical(cCECDevice &dev)
{
if (mCECAdapter == NULL) {
Esyslog ("getLogical CEC Adapter disconnected");
return CECDEVICE_UNKNOWN;
}
cec_logical_address found = CECDEVICE_UNKNOWN;
// Logical address already available
if (dev.mLogicalAddressUsed != CECDEVICE_UNKNOWN) {
return dev.mLogicalAddressUsed;
}
// Try to get logical address from physical address.
// It may be possible that more than one logical address is available
// at a physical address!
if (dev.mPhysicalAddress != 0) {
cec_logical_addresses devices = mCECAdapter->GetActiveDevices();
for (int j = 0; j < 16; j++)
{
if (devices[j])
{
cec_logical_address logical_addres = (cec_logical_address)j;
if (dev.mPhysicalAddress ==
mCECAdapter->GetDevicePhysicalAddress(logical_addres)) {
dev.mLogicalAddressUsed = logical_addres;
Dsyslog ("Mapping Physical %04x->Logical %d",
dev.mPhysicalAddress, logical_addres);
found = logical_addres;
// Exact match
if (dev.mLogicalAddressDefined == logical_addres) {
return logical_addres;
}
}
}
}
}
if (found != CECDEVICE_UNKNOWN) {
return found;
}

// No mapping available, so try as last attempt the defined logical address,
// if available.
if (dev.mLogicalAddressDefined == CECDEVICE_UNKNOWN) {
Esyslog("No fallback logical address for %04x configured", dev.mPhysicalAddress);
return CECDEVICE_UNKNOWN;
}
// Ensure that we don't send accidentally to the own VDR address.

cec_logical_addresses own = mCECAdapter->GetLogicalAddresses();
if (own[dev.mLogicalAddressDefined]) {
Esyslog("Logical address of physical %04x is the VDR", dev.mPhysicalAddress);
return CECDEVICE_UNKNOWN;
}
// Check if device is available.
if (!mCECAdapter->PollDevice(dev.mLogicalAddressDefined)) {
Esyslog("Logical address not available", dev.mLogicalAddressDefined);
return CECDEVICE_UNKNOWN;
}

dev.mLogicalAddressUsed = dev.mLogicalAddressDefined;
return dev.mLogicalAddressDefined;
}


void cCECRemote::WaitForPowerStatus(cec_logical_address addr, cec_power_status newstatus)
{
cec_power_status status;
int cnt = 0;
cCondWait w;

do {
w.Wait(100);
status = mCECAdapter->GetDevicePowerStatus(addr);
cnt++;
} while ((status != newstatus) && (cnt < 50) && (status != CEC_POWER_STATUS_UNKNOWN));
}

/*
* Special exec which handles the svdrp CONN/DISC which may come
* from this executed shell script
*/
void cCECRemote::Exec(cCmd &execcmd)
{
cCmd cmd;
Dsyslog("Execute script %s", execcmd.mExec.c_str());
mInExec = true;
pid_t pid = fork();
if (pid < 0) {
Esyslog("fork failed");
mInExec = false;
return;
}
else if (pid == 0) {
execl("/bin/sh", "sh", "-c", execcmd.mExec.c_str(), NULL);
Esyslog("Exec failed");
abort();
}

do {
cmd = WaitExec(pid);
Dsyslog ("(%d) ExecAction %d Val %d",
cmd.mSerial, cmd.mCmd, cmd.mVal);
switch (cmd.mCmd) {
case CEC_EXIT:
Dsyslog("cCECRemote script stopped");
break;
case CEC_RECONNECT:
Dsyslog("cCECRemote reconnect");
Disconnect();
sleep(1);
Connect();
break;
case CEC_CONNECT:
Dsyslog("cCECRemote connect");
Connect();
break;
case CEC_DISCONNECT:
Dsyslog("cCECRemote disconnect");
Disconnect();
break;
default:
Esyslog("Unexpected action %d Val %d", cmd.mCmd, cmd.mVal);
break;
}
Csyslog ("(%d) Action finished", cmd.mSerial);
if (cmd.mSerial != -1) {
mProcessedSerial = cmd.mSerial;
mCmdReady.Signal();
}
} while (cmd.mCmd != CEC_EXIT);
mInExec = false;
}
/*
* Wait until a command is put into the exec command queue.
* If a command was received remove it and return the received command.
*/
cCmd cCECRemote::WaitExec(pid_t pid)
{
Csyslog("WaitExec");
int stat_loc = 0;
mExecQueueMutex.Lock();
while (mExecQueue.empty()) {
mExecQueueMutex.Unlock();
if (mExecQueueWait.Wait(250)) {
Csyslog(" Signal");
}
else {
if (waitpid (pid, &stat_loc, WNOHANG) == pid) {
Dsyslog(" Script exit with %d", WEXITSTATUS(stat_loc));
cCmd cmd(CEC_EXIT);
return cmd;
}
}
mExecQueueMutex.Lock();
}

cCmd cmd = mExecQueue.front();
mExecQueue.pop_front();
mExecQueueMutex.Unlock();
return cmd;
}


/*
* Put a complete command queue into the worker command queue for execution.
*/
void cCECRemote::PushCmdQueue(const cCmdQueue &cmdList)
{
if (mCECAdapter == NULL) {
Esyslog ("PushCmdQueue CEC Adapter disconnected");
return;
}
mWorkerQueueMutex.Lock();
for (cCmdQueueIterator i = cmdList.begin();
i != cmdList.end(); i++) {
mWorkerQueue.push_back(*i);
}
mWorkerQueueMutex.Unlock();
mWorkerQueueWait.Signal();
}

/*
* Put a command into the worker command queue for execution.
*/
void cCECRemote::PushCmd(const cCmd &cmd)
{
Csyslog("cCECRemote::PushCmd %d (size %d)", cmd.mCmd, mWorkerQueue.size());

mWorkerQueueMutex.Lock();
mWorkerQueue.push_back(cmd);
mWorkerQueueMutex.Unlock();
mWorkerQueueWait.Signal();
}

/*
* Put a command into the worker command queue and wait for execution.
*/
void cCECRemote::PushWaitCmd(cCmd &cmd, int timeout)
{
int serial = cmd.getSerial();
cmd.mSerial = serial;
bool signaled = false;

Csyslog("cCECRemote::PushWaitCmd %d ID %d (WQ %d EQ %d)",
cmd.mCmd, serial, mWorkerQueue.size(), mExecQueue.size());

// Special handling for CEC_CONNECT and CEC_DISCONNECT when called
// from exec state (used for out of band processing of svdrp commands
// coming from a script, executed by a command queue.
if (((cmd.mCmd == CEC_CONNECT) || (cmd.mCmd == CEC_DISCONNECT)) && mInExec){
Csyslog("ExecQueue");
mExecQueueMutex.Lock();
mExecQueue.push_back(cmd);
mExecQueueMutex.Unlock();
mExecQueueWait.Signal();
}
// Normal handling
else {
mWorkerQueueMutex.Lock();
mWorkerQueue.push_back(cmd);
mWorkerQueueMutex.Unlock();
mWorkerQueueWait.Signal();
}

// Wait until this command is processed.
do {
signaled = mCmdReady.Wait(timeout);
} while ((mProcessedSerial != serial) && (signaled));
if (!signaled) {
Esyslog("cCECRemote::PushWaitCmd timeout %d %d", mProcessedSerial, serial);
}
else {
Csyslog("cCECRemote %d %d", mProcessedSerial, serial);
}
}

/*
* Wait until a command is put into the worker command queue.
* If a command was received remove it and return the received command.
*/
cCmd cCECRemote::WaitCmd(int timeout)