" #260

wants to merge 487 commits into


None yet

6 participants


No description provided.

fetzerch and others added some commits Jan 1, 2013
@fetzerch fetzerch [mythtv-cmyth] Remove unused define SEEK_POSSIBLE 6786544
@janbar @fetzerch janbar [cmyth] Artwork fix
- Checking DB version >= 1279
- When season doesn't exist then get other one
@janbar @fetzerch janbar [mythtv-cmyth] Timer state in error after disabling
- Don't check unused states. Default will be CANCELLED.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' e49593b
@janbar @fetzerch janbar [cmyth] Fix LiveTV chain not beeing updated with MythTV 0.24
Process event CHAIN_UPDATE during WATCH period because DONE_RECORDING
is never sent in time with MythTV 0.24.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 50261ab
@janbar @fetzerch janbar [cmyth] libcmyth cleanups (inttypes)
Rework all numeric types and use the correct types from inttypes.h
to solve portability issues.
Rework comments and remove unused docs/declarations.
More smaller cleanups and todos in libcmyth.
@janbar @fetzerch janbar [mythtv-cmyth] Fix inttypes e5f6df2
@janbar @fetzerch janbar [cmyth] Added chanid to cmyth_mysql_get_guide
Get EPG only for given channel to avoid loading too much data.
@janbar @fetzerch janbar [mythtv-cmyth] Improve GetGuide (retreive EPG only for given channel)
Avoid parsing EPG in a loop and process only necessary data: less cpu, less memory.
@janbar @fetzerch janbar [cmyth] Force LiveTV chain update in done_recording
- Backend could return old program during chain update. When old recording is completed and the chain has not been updated during normal flow, i retry update 4 times in "done_recording" before returning error. That is a workaround against this abnormal case using Myth protocol. An other fix could be use DB (tvchain) but need huge rework.
- Multi players: Call "get_cur_proginfo" only when chainid matches.
@janbar @fetzerch janbar [cmyth] Resolve LiveTV chain seek
- cmyth_file_seek: Fix read position to the position returned by backend.
- cmyth_livetv_chain_seek: Force SEEK_SET because read position could not be the same when switching to an other file. Returns absolute position in the chain.
@janbar @fetzerch janbar [cmyth] Switch on read does'nt reset the file position to 0
- When next file in the chain have been already requested, playback continues from the last position. So after switching file during playback, we seek to position 0.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' a9637d5
@janbar @fetzerch janbar [cmyth] 'Monitor' announcement. Close nicely connections.
- Choose announcement 'Monitor' for event connection to be not blocking.
- Send message 'DONE' before shutdown 'Playback' and 'Monitor' connection.
- Break loop on error in rcv_okay and rcv_feedback.
@janbar @fetzerch janbar [mythtv-cmyth] Add IsListening to event handler
- Check event connection in API functions
- Remove unneeded NULL checks for event handler
@janbar @fetzerch janbar [cmyth] Add cmyth_mysql_recordingrule_from_template
- Update program to get category_type
- Update rules
@janbar @fetzerch janbar [mythtv-cmyth] Add recording rule template
Use can choose between usage of MythTV and internal recording
rule template. For MythTV >= 0.26 category based templates are used.
For older version the global settings are loaded.
As alternative an addon internal template can be created and used.
@fetzerch fetzerch [mythtv-cmyth] Unify internal recording rule template
Adjust labels and default values with MythTV.
@fetzerch fetzerch [mythtv-cmyth] Win32: Add addon files to project
Add addon.xml.in, settings.xml and english string.po to VS project files.
@fetzerch fetzerch [mythtv-cmyth] Fix crash when starting Live TV after a failed attempt f5dd95c
@fetzerch fetzerch [mythtv-cmyth] Release v1.6.8 b6f3f4f
@fetzerch fetzerch [cmyth] Fix ASK_RECORDING
Properly return data buffer and program info.
@fetzerch fetzerch [mythtv-cmyth] Start development v1.6.9 d303934
@fetzerch fetzerch [cmyth] Add cmyth_recorder_cancel_next_recording 259e0eb
@fetzerch fetzerch [mythtv-cmyth] Add Live TV conflict handling
Scheduled recordings will hang in Myth TV backend  if ASK_RECORDING is ignored.
Correct responses are either CANCEL_NEXT_RECORDING or stopping playback.

This adds a setting letting the user define how to handle conflicts:
 - Always prefer Live TV
 - Always prefer recording
 - Prefer Live TV only if the recording has later slot (default)

See MythTV: libs/libmythtv/tv_play.cpp: TV::AskAllowRecording.
@fetzerch fetzerch [mythtv-cmyth] Fixes from static analyze
Corrects a couple of small issues shown by a static analyze using cppcheck.
@fetzerch fetzerch [cmyth] Win32: Add cmyth_msc.h to project files cc4664e
@fetzerch fetzerch [cmyth] Win32: Fix socket connection hang
Functions in libcmyth usually return a negative error value (-ERRNO).
An incorrect define made functions that return the error -ECANCELED
and -ETIMEDOUT a positive value, indicating a successful operation.
Due to this, socket connection problems were not handled correctly
on Windows.

Affected functions are cmyth_conn_check_block, cmyth_file_read,
cmyth_ringbuf_read, cmyth_send_message, cmyth_rcv_length,
cmyth_conn_refill and cmyth_rcv_data.

One manifestation is that a restart of the backend caused the addon
to hang.
@fetzerch fetzerch [cmyth] Removed commented out lines from cmyth_msc.h 4afb366
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master'
@fetzerch fetzerch [mythtv-cmyth] Define common size of all RCV and TCP RCV buffers 0a15979
@fetzerch fetzerch [cmyth] Use CLIENT_FOUND_ROWS option
Setting this option makes mysql_affected_rows return
the number of rows found, or better number of rows
matching the WHERE clause.

This fixes functions that return mysql_affected_rows
as error indicator. Those functions would return an
error if an UPDATE query would reset an already
existing value.

Affected are:
@fetzerch fetzerch [mythtv-cmyth] Clean image cache only on startup/shutdown
Cleaning the images after a given time period is erroneous.
Channel icons won't be reloaded and it might cause unneeded
cpu load.
@janbar @fetzerch janbar [mythtv-cmyth] Check if preview exists before enqueue
Check if icon preview exists before enqueuing the download job.
If not the backend will send an event to update the recording when preview has been generated.
Then Event handler will force refresh.
@janbar @fetzerch janbar [mythtv-cmyth] Proginfo is already filled. Do not force cmyth_proginf…

- cmyth_proginfo_fill() forces update to get details, but we have already all details. Remove this call.
@fetzerch fetzerch Revert "[mythtv-cmyth] Define common size of all RCV and TCP RCV buff…

This reverts commit 0a15979.

That commit needs more testing. It increases stuttering and 'Buffering' dialogs
when playing Live TV.
@fetzerch fetzerch [mythtv-cmyth] Changelog v1.6.9 f7d154e
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master'
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 9d91057
@fetzerch fetzerch [mythtv-cmyth] Start development v1.7.10 3c94b41
@fetzerch fetzerch [mythtv-cmyth] Cosmetics: fix typo and unify Set/GetFrameRate eeb31ca
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 716997d
@fetzerch fetzerch [mythtv-cmyth] Start development v1.7.11 8501c92
@janbar @fetzerch janbar [mythtv-cmyth] Add more logging to OpenLiveStream
- Log on "done"
- Log on fail case
@janbar @fetzerch janbar [cmyth] Fix switching to first file on setting up Live TV chain
This fixes a crash that was reported when using analog tuners or pre 0.25 backends.

The current chain element is -1, so switch dir(ection) should be 1 to switch to
the next one. Fixed by calling cmyth_livetv_chain_switch_last().

Program terminated with signal 11, Segmentation fault.
0 0x00007fa2441a27ef in cmyth_livetv_chain_seek (whence=<optimized out>,
        offset=0, rec=0x7fa21c0bc188) at livetv.c:1103
  1103 offset += rec->rec_livetv_chain->chain_files[cur]->file_req;

Fixes #99
@janbar @fetzerch janbar [cmyth] Return error (-1) on seek out of range
- cmyth_file_seek():
  Return -1 on invalid seek.
- cmyth_livetv_chain_seek():
  WHENCE_SET: Wanted "current" should be less than chain "count" else the seek cannot to be provided. So return error.
@janbar @fetzerch janbar [cmyth] Set seek buffer in cmyth_file_seek to 4K dfcd825
@janbar @fetzerch janbar [cmyth] Replace library wide mutex with individual mutexes on certain…
… data structures

Backported from cmyth upstream.
@janbar @fetzerch janbar [mythtv-cmyth] Recording file: Release connections on close 6572069
@fetzerch fetzerch [cmyth] Connect to the correct host in cmyth_conn_connect_file
The function cmyth_conn_connect_file must establish the data connection
to the same host as the control connection. Otherwise we might
send REQUEST_BLOCK on the control connection to host A while
expecting the data packet from host B.

For recordings made on a different (slave) backend, the old code
connected the data socket to the host given in the proginfo (slave)
whereas the given control connection could be established to a
different host (most likely the master backend).
In those cases, REQUEST_BLOCK was sent to the master backend,
but the data was expected to be received from the slave backend.

The new code enforces control and data connections on the same host.
A file connection to a slave backend can be established by first
creating a control connection to the slave backend and then calling
cmyth_conn_connect_file using that control connection.
@fetzerch fetzerch [mythtv-cmyth] Dedicated control connection for recording playback
This creates a dedicated control connection for recording playback.
The current implementation will always request the stream from the
master backend.

Future implementations should adapt to MythTV's ProgramInfo::GetPlaybackURL
and first try to read the file locally and as a fallback play it from
the slave it was recorded on.
@fetzerch fetzerch [cmyth] Align buffer sizes
This adds a buflen parameter to cmyth_livetv_chain_setup to specify
the receive buffer from outside.

In addition this removes setting tcp_buflen to the value returned by
getsockopt(SO_RCVBUF). The reason is that getsockopt will return different
values depending on the platform. Linux systems double the value since
they reserve half of the buffer for metadata. Other systems don't do this
and since that value is reused as input for setsockopt when starting playback,
we create buffers of the doubled size.
@fetzerch fetzerch [mythtv-cmyth] Define common buffer sizes
- TCP receive buffers are set to 128000 (like MythTV's MythSocket class)
- For chain, file and path, buffer is only used to receive backend response of query ANN FileTransfer.
  So 64 bytes is large enough. This value is defined by RCV_BUF_DATA_SIZE.
- For artworks downloader, the buffer size is fixed to 32000. This value is defined by RCV_BUF_IMAGE_SIZE.
- For control, buffer is fixed to 32000. This value is defined by RCV_BUF_CONTROL_SIZE.
@janbar @fetzerch janbar [cmyth] Setup DST unavailable for new timestamp a7ef407
@janbar @fetzerch janbar [cmyth] Review of "GET_RECORDING TIMESLOT"
- Review error handling of cmyth_timestamp functions.
- Add new function cmyth_timestamp_to_numstring() to support DateTime big endian format used by "GET_RECORDING TIMESLOT".
- Remove unix time conversion in cmyth_proginfo_get_from_timeslot() and use cmyth_timestamp_t instead.
@janbar @fetzerch janbar [mythtv-cmyth] Review of "GET_RECORDING TIMESLOT"
- Remove unix time conversion and use MythTimestamp class instead.
@fetzerch fetzerch [cmyth] Fix warning after 'Review of "GET_RECORDING TIMESLOT"' 36e3683
@teeedubb @fetzerch teeedubb [mythtv-cmyth ]Remove 'failed to connect to mythtv backend' notification
Currently if the addon is unable to connect to a previously working backend
(because backend is suspended or unreachable via network) it displays a pop up
every 10 or so seconds, which appears in all menus and over video/visualizations
and plays a notification sound.
@fetzerch fetzerch [cmyth] Improve separator checking in cmyth_rcv_string
This improves the checking for string separators []:[].
In case a string ends with a part of a separator, the
code did not find the correct separator.

It was reported by a user that a recording "Title ["
breaks the loading of recordings because it does not
recognize the string's end. The protocol showed
"...[]:[]Title[[]:[]Subtitle...", and cmyth_rcv_string
returned "Title[[]:[]Subtitle".
@fetzerch fetzerch [mythtv-cmyth] Revert TCP_RCV_BUF_DATA_SIZE to prevent stuttering
A value of 128000 causes stuttering on linux x68_64.
Reverting to the original value of 65536.
@fetzerch fetzerch [mythtv-cmyth] Start development v1.7.12 b9c96a9
@janbar @fetzerch janbar [cmyth] Connect Playback or Monitor
- New functions to connect as Monitor or Playback to the backend
@janbar @fetzerch janbar [mythtv-cmyth] Connect Playback or Monitor
Add 'playback' flag to the initializer of MythConnection and select annoucement type.
- Recording stream control connection use Playback annoucement to prevent backend shutdown.
- Addon control connection use Monitor annoucement to allow backend shutdown.
@fetzerch fetzerch [cmyth] Add cmyth_mysql_get_prog_finder_chan
Function allows to find the current program on the given channel.

Thanks to Aubrien for the patch.
@fetzerch fetzerch [mythtv-cmyth] Set start/end time for instant recordings correctly
Add FindCurrentProgram to find the currently active program on a given
channel. When adding a instant recording, set the correct start/end time
from this program.

Thanks to Aubrien for the patch.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 60d232c
@fetzerch fetzerch [mythtv-cmyth] Fix stopping Live TV
This fixes stopping of Live TV by returning 0 in ReadLiveStream.
Stopping Live TV is currently used for the conflict handling.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master'
@fetzerch fetzerch win32: Make sure that all addon projects define TARGET_WINDOWS
In the recent PVR API sync, _WIN32 has been replaced by TARGET_WINDOWS.
Since this is a project specific define and not a system variable,
we have to make sure that all PVR addons define this in their project

Compilation of addons without TARGET_WINDOWS fails with:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xxresult(280):
  error C2953: 'std::tr1::_Result_of1<_Rx(__thiscall _Arg0::* )(void),_Farg0&>':
    class template has already been defined
c:\program files (x86)\microsoft visual studio 10.0\vc\include\xxresult(172):
  see declaration of 'std::tr1::_Result_of1<_Rx(__thiscall _Arg0::* )(void),_Farg0&>'
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' bd7bc59
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' b689333
@fetzerch fetzerch [mythtv-cmyth] win32: Add TARGET_WINDOWS for release builds 7087680
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 526d014
@janbar @fetzerch janbar [cmyth] New EPG structures replacing "cmyth_program"
- Memory segments of shared pointers are now handled by librefmem tools.
@janbar @fetzerch janbar [mythtv-cmyth] New EPG structures replacing "cmyth_program"
- New class MythEPGInfo as smart pointer for cmyth_epginfo.
- Memory segments of shared pointers are now handled by librefmem tools.
@janbar @fetzerch janbar [cmyth] Code and headers cleanup
- Move some function declarations
- Remove deprecated function cmyth_get_delete_list
- Rename cmyth_mysql_get_commbreak_list to cmyth_mysql_query_commbreak_list
@fetzerch fetzerch [cmyth] Update cmyth_proginfo_delete_recording
This updates cmyth_proginfo_delete_recording to use the different

 1-55: DELETE RECORDING[]:[]<proginfo>
56-58: DELETE RECORDING chanid recstartts [FORCE/NO_FORCE]

For newer protocol versions, this allows also to force deletion and
allows to rerecord a recording.
@fetzerch fetzerch [mythtv-cmyth] Update DeleteRecording and add DeleteAndForgetRecording fb17306
@fetzerch fetzerch [cmyth] Add cmyth_timestamp_utc_from_unixtime aa3f99e
@fetzerch fetzerch [mythtv-cmyth] Add menuhook 'Delete and re-record' c832e44
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' ae59bd8
@janbar @fetzerch janbar [cmyth] Fix memory leak in cmyth_conn_connect_path
The call to cmyth_file_create has been moved to the end of the function.
It hasn't been removed at its original place leading to a memory leak.
@fetzerch fetzerch [cmyth] Free chanstr in cmyth_channel_destroy
Commit 9d115f3 introduced refmem for
chanstr. Therefore it has to be freed now in cmyth_channel_destroy to
prevent leaking memory.
@fetzerch fetzerch [mythtv-cmyth] Fix missing free in MythChannel::Number
Commit 9d115f3 introduced refmem for
chanstr. Therefore it has to be freed now in cmyth_channel_destroy to
prevent leaking memory.
@fetzerch fetzerch [mythtv-cmyth] Fix memory leak in MythDatabase::GetChannelGroups
The function cmyth_mysql_get_channelids_in_group writes the list of
channel ids for a channel group into an array of unsigned int.
The allocation is done using ref_alloc.
We have to call ref_release also for a channelCount of 0 because
ref_alloc will also allocate memory when called with size parameter of 0.
@fetzerch fetzerch [cmyth] Free db settings in cmyth_database_destroy c83f12d
@fetzerch fetzerch [cmyth] Remove unnecessary calls to mysql_close in cmyth_db_check_con…

The mysql connection is already closed in cmyth_database_close.
@fetzerch fetzerch [mythtv-cmyth] Prevent MythFile::Length from returning negative number
The function cmyth_file_length returns negative numbers in case of an
error. Since MythFile::Length returns an unsigned value, this might lead into
unexpected behavior.
@fetzerch fetzerch [mythtv-cmyth] Return proper number of recordings in FillRecordings
The function PVRClientMythTV::FillRecordings has to return the number of
visible recordings. Seems to be caused by forgotten curly braces.
@janbar @fetzerch janbar [cmyth] Return consistent errors in storagegroup.c
- Return consistent ERROR values
- Use NULL instead 0 for null pointers
@janbar @fetzerch janbar [cmyth] Use cmyth_mysql_query for DML statement
Use cmyth_mysql_query instead cmyth_mysql_query_result to avoid error messages.
@janbar @fetzerch janbar [cmyth] Fix checking for valid connection in connection.c
This fixes a couple of 'Dereference before null check' issues in
@janbar @fetzerch janbar [cmyth] Return consistent errors in connection.c a825153
@janbar @fetzerch janbar [cmyth] Add cmyth_mysql_keep_livetv_recording
The function disables/enables auto expiration and sets the storage group to
'Default'/'LiveTV' to keep/release a recording.
@janbar @fetzerch janbar [cmyth] Add cmyth_proginfo_storagegroup
Returns the storage group for a recording.
@janbar @fetzerch janbar [cmyth] Add cmyth_proginfo_generate_pixmap
Use QUERY_GENPIXMAP2 to generate missing pixmaps. (protocol version >=61)
@janbar @fetzerch janbar [cmyth] Change log level in cmyth_proginfo_get_from_timeslot
Change log level for error message "...didn't recieve OK as response"
from ERROR to NOTICE since it is not an error, just indicates that a
recording couldn't be found.
@janbar @fetzerch janbar [cmyth] Cosmetics in event.c 371fe9f
@janbar @fetzerch janbar [cmyth] Cosmetics in socket.c 1bb089e
janbar and others added some commits Aug 21, 2013
@janbar @fetzerch janbar [cmyth] Cosmetics in file.c 530a1ed
@janbar @fetzerch janbar [cmyth] Improve global speed of Live TV playback (read and seek)
Hold handled chain and file and not dereference any more.
Now client doesn't need to hold a mutex because handled resources will never be
freed during operations. Also it is possible because none of volatile values are
critical in the context of these operations.
@janbar @fetzerch janbar [mythtv-cmyth] Improve global speed of Live TV playback (read and seek)
Update according to cmyth changes. Client doesn't need to hold a mutex anymore,
because handled resources will never be freed during operations.
@janbar @fetzerch janbar [cmyth] cmyth_rcv_free_inputlist: cmyth_rcv_ulong() sourceid failed (22)
Bail out when feedback is "EMPTY_LIST"
@janbar @fetzerch janbar [cmyth] Fix memory leak in cmyth_livetv_chain_setup ccf7cd1
@janbar @fetzerch janbar [cmyth] Remove unused Live TV functions
After the Live TV chain has been reviewed, a chain entry cannot be incomplete.
So a valid chain entry is added in one pass.
Therefore chain_add_url, chain_add_file and chain_add_prog can be removed.
@janbar @fetzerch janbar [cmyth] Add cmyth_recordingrule_dup to recordingrule.c ff6635f
@janbar @fetzerch janbar [cmyth] Add field parentid to cmyth_recordingrule
This adds the field parentid to cmyth_recordingrule in order to keep
track of the main recordingrule (in case of an override rule).
For main recordingrules, this value will be 0.
@janbar @fetzerch janbar [cmyth] Cosmetics in cmyth_local.h ad8b2a6
@janbar @fetzerch janbar [cmyth] Filter out manual programs
For 'manual search' recordings, the backend creates entries in the program
table with 'manualid' set to the related rule.

These programs should not selected in the database queries:
- cmyth_mysql_get_guide
- cmyth_mysql_get_prog_finder_char_title
- cmyth_mysql_get_prog_finder_time
@janbar @fetzerch janbar [cmyth] Extend debug log in cmyth_mysql_get_guide b92bac4
@janbar @fetzerch janbar [cmyth] Cosmetics in recordingrule.c 6ac6831
@janbar @fetzerch janbar [cmyth] Cleanup leftover cmyth_mysql_get_prog_finder_time2 in cmyth.h 72cb60e
@janbar @fetzerch janbar [cmyth] Let backend handle findid for recordingrules
The field findid is handled by the backend and should only be set on
@janbar @fetzerch janbar [cmyth] Fix type initialization in cmyth_recordingrule_init
A new recording rule should be initialized with type RRULE_NOT_RECORDING
instead of RRULE_DONT_RECORD. The type RRULE_DONT_RECORD is reserved
for override rules.
@janbar @fetzerch janbar [cmyth] Add attime parameter to cmyth_mysql_get_prog_finder_chan
Add 'attime' to find program related to a recording rule.
The new parameter must be set to current time to keep old functionality.
@janbar @fetzerch janbar [cmyth] Cosmetics in mythtv_mysql.c 17a0362
@janbar @fetzerch janbar [mythtv-cmyth] Align MythDatabase::FindCurrentProgram with cmyth change fcaa81b
@janbar @fetzerch janbar [mythtv-cmyth] Align MythDatabase::DeleteRecordingRule with cmyth change 9c6e4e3
@janbar @fetzerch janbar [mythtv-cmyth] Add MythRecordingRule::DuplicateRecordingRule 86b8c00
@janbar @fetzerch janbar [mythtv-cmyth] Add ParentID and SetParentID to MythRecordingRule ac66f78
@janbar @fetzerch janbar [cmyth] Add error checking for adding and updating recording rules da34aa6
@janbar @fetzerch janbar [cmyth] Improve cmyth_mysql_delete_recordingrule
Delete recording rule didn't cleanup linked rows in tables oldfind and program.
@janbar @fetzerch janbar [mythtv-cmyth] Add MythConnection::GenerateRecordingPreview
This function triggers the backend to generate a preview for the given
@janbar @fetzerch janbar [mythtv-cmyth] Keeping live recordings doesn't update recording list
This case occurs when keeping a live recording and stopping to watch it:
MythTV creates a new rule (recordid) for the recording, which is part
of our UID. So replace the old live recording without rule (recordid=0) with
this one.
@janbar @fetzerch janbar [mythtv-cmyth] Add MythProgramInfo::IsLiveTV c498d59
@janbar @fetzerch janbar [cmyth] Add cmyth_recorder_set_live_recording
Recording live TV show to keep it
@janbar @fetzerch janbar [mythtv-cmyth] Add MythDatabase::KeepLiveTVRecording
The function triggers the backend to disables/enables auto expiration and sets
the storage group to 'Default'/'LiveTV' to keep/release a Live TV recording.
@janbar @fetzerch janbar [mythtv-cmyth] Add group 'LiveTV' in recordings view
Add group Live TV that shows LiveTV recordings.
Recordings with duration less than 5s still not be visible (dummy recordings).
Add channel icon as recording preview.
@janbar @fetzerch janbar [mythtv-cmyth] Enabling 'Keep LiveTV Recording'
Live timer doesn't create a recording rule anymore. Now we set recorder and keep
recording. Backend will create rule as needed for us and no more recorder used.

Add menuhook 'Keep LiveTV recording'. The improvement is extended to keep old
live recordings using menuhook in recording screen.
@janbar @fetzerch janbar [mythtv-cmyth] Use IsTunable instead of CheckChannel when switching c…
@janbar @fetzerch janbar [mythtv-cmyth] Revert SwitchChannel improvement and reopen live strea…
…ms again

The free input list is always empty when the recorder is locked or paused and
we reopen the live stream anyway.

Also CheckChannel fails in some cases and can break the recorder and the
@janbar @fetzerch janbar [mythtv-cmyth] Don't store the file control connection in file.c
There is no need to store the file control connection since it is ref counted
in cmyth_file_create. If needed it can be accessed using cmyth_file_control.
@janbar @fetzerch janbar [cmyth] Add support functions for UTC timestamps
In MythTV protocol 0.26 all commands return time values in ISO8601 format
(including a zone flag 'Z'). This patch adds support functions to process those.

The conversion from UTC timestamp to 'time_t' has been banned.
Once a timestamp created as UTC time, it can be formatted to string or others
for processing only.

Add new attribute 'timestamp_isutc' to indicate if a timestamp is in UTC time.
UTC timestamp can be create in two ways:
- by function cmyth_timestamp_utc_from_unixtime
- by function cmyth_timestamp_from_string
  Here if the string is formatted using standard ISO8601 (including 'Z')

Update 'to_string' and 'to_display' functions to consider timestamp_isutc.
Prohibit conversion in all functions using 'mktime' by returning NULL
of (time_t) -1.
Add new function 'cmyth_timestamp_to_utc' to convert local timestamp to
UTC timestamp.
Add new function 'cmyth_timestamp_isutc' to retreive the zone type of
timestamp: 1 = UTC, 0 = local
@janbar @fetzerch janbar [cmyth] Cosmetics in timestamp.c
- Function cmyth_timestamp_from_tm() is locali. Set storage type to static.
- Function cmyth_timstamp_diff() should return number of seconds.
  Use difftime() from standard lib.
@janbar @fetzerch janbar [cmyth] Add Live TV chain info functions
- cmyth_livetv_chain_last returns last index of the chain handle by recorder
- cmyth_livetv_chain_prog returns prog at index from the chain handle by recorder
- cmyth_livetv_chain_file returns file at index from the chain handle by recorder
@janbar @fetzerch janbar [mythtv-cmyth] Rework recordings UID and recording events
Rework recording UID and the handling of recording related events since
this caused many problems (especially because of MythTV protocol changes).

The UID is now formatted like "1002 2013-08-23T14:42:00Z"
and contains the channelid and recstartts as UTC time.
Regardless of the protocol version, the UID uses UTC time only.

Depending of protocol command, the backend messages are filled with time
values in Unix time format or strings using the ISO8601 standard (whereas the
string can contains UTC or local time).
To process recording events from backend we must match the backend message
with recording UIDs.

These changes allow to resolve failure in update file size events and to clear
tricky code.

Cosmetics around recording events
- New function to handle a particular event
- New virtual function MythObserver::UpdateRecordings()
- New function to manage timeout or trigger update recordings
@janbar @fetzerch janbar [mythtv-cmyth] Remove overlapping EPG entries and fill gaps
PVR updates EPG entries to remove overlaps and fills gaps by updating the
start time of entries. This is a problem for the addon to match entries with
the MythTV database using channelid and starttime.

The patch makes sure to remove gaps and overlapping EPG entries before
transferring them to XBMC.
@janbar @fetzerch janbar [mythtv-cmyth] Fix time_t related issues
- time_t is undefined arithmetic type: In GetEPGForChannel(), convert startTime
  to number of minutes since epoch before cast.
- Check times of PVRTimer: If original values equals 0 (NULL),
  time() will return current time as expected.
- Fix timeslot for all
@janbar @fetzerch janbar [mythtv-cmyth] Set numeric addon options to "int"
Resolves the "Need restart" after updating settings.
Requires option "int" to get *int in ADDON_SetSetting().
@janbar @fetzerch janbar [mythtv-cmyth] Reload "Record template" when settings change
No need to restart, the template is loaded on addon start anyway.
@janbar @fetzerch janbar [mythtv-cmyth] Add Filter and SetFilter to MythRecordingRule 4831dd8
@fetzerch fetzerch [cmyth] Fix may be used uninitialized warning in cmyth_rcv_commbreaklist
commbreak.c: In function 'cmyth_rcv_commbreaklist':
commbreak.c:247:23: warning: 'start_type' may be used uninitialized in
this function [-Wmaybe-uninitialized]
commbreak.c:250:27: warning: 'start_mark' may be used uninitialized in
this function [-Wmaybe-uninitialized]
@fetzerch fetzerch [cmyth] Fixed unused variable warnings in mythtv_mysql.c
mythtv_mysql.c: In function 'cmyth_mysql_get_prev_recorded':
mythtv_mysql.c:332:6: warning: unused variable 'n' [-Wunused-variable]

mythtv_mysql.c: In function 'cmyth_mysql_get_guide':
mythtv_mysql.c:413:6: warning: unused variable 'n' [-Wunused-variable]

mythtv_mysql.c: In function 'cmyth_mysql_get_prog_finder_char_title':
mythtv_mysql.c:523:6: warning: unused variable 'n' [-Wunused-variable]
@fetzerch fetzerch [cmyth] Fix differ in signedness warning when using __cmyth_rcv_data
event.c: In function 'cmyth_event_get_message':
event.c:245:3: warning: pointer targets in passing argument 3 of
'__cmyth_rcv_data' differ in signedness [-Wpointer-sign]
In file included from event.c:24:0:
./cmyth_local.h:311:12: note: expected 'unsigned char *' but argument is
of type 'char *'

socket.c: In function '__cmyth_rcv_okay':
socket.c:654:4: warning: pointer targets in passing argument 3 of
'__cmyth_rcv_data' differ in signedness [-Wpointer-sign]

In file included from socket.c:30:0:
./cmyth_local.h:311:12: note: expected 'unsigned char *' but argument is
of type 'char *'
@janbar @fetzerch janbar [mythtv-cmyth] Cosmetics in tools.h 3c1f42a
@janbar @fetzerch janbar [mythtv-cmyth] Fix calculation of daytime in tools.h 3421565
@janbar @fetzerch janbar [mythtv-cmyth] Refactoring schedule management
New class MythScheduleManager handles recording operations.
All related code has been refactored.

Some rules depend on the backend version. Those are handled by a version
handler, that can be extended, when a new version should be supported.

In the future main services like 'Schedule recording', 'Delete Recording'
could be transfered to the version helper as needed.
@fetzerch fetzerch [cmyth] Fix warning in mythtv-mysql.c 3592efc
@fetzerch fetzerch Revert "[mythtv-cmyth] Use StartTime instead of RecordingStartTime fo…
…r recordings."

XBMC identifies recordings by {title, recordingTime}. Using the StartTime
can confuse XBMC when there are multiple recordings for a single EPG program.
This can happen for example when the backend is restarted.

This reverts commit f8ceee6.
@janbar @fetzerch janbar [mythtv-cmyth] Fix creating repeating rules
The start time of repeating timer is always relative to the current day.
So check timer.bIsRepeating before testing for current program.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master'
@BigYesh @fetzerch BigYesh [cmyth] Handle MythTV priorities correctly
MythTV priorities can be significantly larger than the limits of a int8.
This change allows users with recordings that have priorities outside of the
int8 range to load recordings and use the MythTV PVR addon.

Without this, the addon will fail to populate the recordings list if there are
any recordings that had a priority outside the int8 range.
@nerddtvg @fetzerch nerddtvg [cmyth] Update SET_BOOKMARK for protocol >= 77
For protocol >= 77, do not send trailing blank parameter with SET_BOOKMARK
This useless parameter was removed in MythTV 0.27, protocol 77.

@nerddtvg @fetzerch nerddtvg [cmyth] Add function cmyth_mysql_get_recording_seek_offset
Function returns offset for mark and type from position map of recording
(table recordedseek).
@nerddtvg @fetzerch nerddtvg [mythtv-cmyth] EDL: Use position/duration/seeking since MythTV 0.27
Since MythTV 0.27, the backend provides accurate position/duration/seeking with
non-constant frame rates.

Depending of the backend database version, we check if the new type of mark (33)
exists else fallback using old method based on framerate.

Note that to get the benefit of these changes for preexisting recordings,
it may be necessary to run "mythcommflag --rebuild" on affected recordings.
@nerddtvg @fetzerch nerddtvg [mythtv-cmyth] When EDL start_mark is zero, assume 0ms offset. Skip D…
…B seek

mythcommflag does not always rebuild the recordedseek table starting from 0,
which can put the start of a break that is at the beginning of a recording
off by a half-second or more.

Also add in a check to see if a DB seek for end_mark offsets failed. If they
failed, fallback to the static framerate guess.
@fetzerch fetzerch [mythtv-cmyth] Add dependency to xbmc.pvr version 1.8.1
Recent XBMC builds contain xbmc.pvr in version 1.8.1 and therefore
the dependency to version 1.8.0 cannot be met.

This fixes the issue that the addon zip file couldn't be installed any
more with the error message: "Dependencies not met".
@janbar @fetzerch janbar [cmyth] Fix crash in cmyth_connect_addr and cmyth_reconnect_addr
Fix crash caused by incorrect format string parameter ordering with
cmyth_dbg/vsnprintf. Adapted log message.

 0  0x00007fdcaa025040 in _IO_vfprintf_internal (s=s@entry=0x7fdc31877420,
      format=<optimized out>, format@entry=0x7fdc85dda4b8 "%s: connect failed
      on port %u to '%s' (%d)\n", ap=ap@entry=0x7fdc318785d8) at vfprintf.c:1655
 1  0x00007fdcaa0e7c00 in ___vsnprintf_chk (s=0x7fdc31877597
      "cmyth_reconnect_addr: connect failed on port 1610688128 to '000",
      maxlen=<optimized out>, flags=flags@entry=1,
      slen=slen@entry=18446744073709551615, format=format@entry=0x7fdc85dda4b8
      "%s: connect failed on port %u to '%s' (%d)\n",
      args=args@entry=0x7fdc318785d8) at vsnprintf_chk.c:63
 2  0x00007fdc85dbc5e5 in vsnprintf (__fmt=0x7fdc85dda4b8 "%s: connect failed
      on port %u to '%s' (%d)\n", __n=<optimized out>, __s=<optimized out>,
      __ap=0x7fdc318785d8) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:77
 3  __cmyth_dbg (level=0, fmt=0x7fdc85dda4b8 "%s: connect failed on port %u to
      '%s' (%d)\n", ap=ap@entry=0x7fdc318785d8, ctx=0x7fdc85ffa160
      <cmyth_debug_ctx>) at ../include/debug.h:60
 4  0x00007fdc85dbc777 in cmyth_dbg (level=level@entry=0,
      fmt=fmt@entry=0x7fdc85dda4b8 "%s: connect failed on port %u to '%s'
      (%d)\n") at debug.c:114
 5  0x00007fdc85db9a38 in cmyth_reconnect_addr (addr=0x7fdc24000b90,
      conn=0x7fdc60017638) at connection.c:371
@fetzerch fetzerch [mythtv-cmyth] Return shared pointers in MythScheduleManager
In the current implementation, MythScheduleManager holds the upcoming
recordings and recording rules in data structures that use smart
pointers. However, these were always passed as raw pointers to the
outside (pvrclient-mythtv).

With this patch, the API of the MythScheduleManager is changed to always pass
data within smart pointers.

In rare cases, PVRClientMythTV::GetTimers() gets called while
m_scheduleManager->Update() is still running. Update() cleared the list
of upcoming recordings which deleted all MythProgramInfos since the only
reference was held from the list. This could lead into GetTimers
accessing freed memory.

0x4809f534 in cmyth_proginfo_start () from
0  0x4809f534 in cmyth_proginfo_start () from
1  0x48076ba8 in MythProgramInfo::StartTime (this=<value optimized out>)
    at src/cppmyth/MythProgramInfo.cpp:147
2  0x4805ab9c in PVRClientMythTV::GetTimers (this=<value optimized out>,
     handle=<value optimized out>) at src/pvrclient-mythtv.cpp:934
3  0x004dc6b4 in PVR::CPVRClient::GetTimers(PVR::CPVRTimers*) ()
4  0x004ebaec in PVR::CPVRClients::GetTimers(PVR::CPVRTimers*) ()
5  0x00bdb668 in PVR::CPVRTimers::Update() ()
   0x00bb5830 in PVR::CPVRManager::ExecutePendingJobs() ()
7  0x00bbae00 in PVR::CPVRManager::Process() ()
8  0x00ebc39c in CThread::Action() ()
9  0x00ebce30 in CThread::staticThread(void*) ()
10 0x405b2a90 in start_thread () from /lib/libpthread.so.0
11 0x41226fb8 in clone () from /lib/libc.so.6
@fetzerch fetzerch [mythtv-cmyth] Changelog for v1.8.13 0f1c939
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 12460b8
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' b099b73
@fetzerch fetzerch [mythtv-cmyth] Start development v1.9.14 8d24389
@janbar @fetzerch janbar [cmyth] Return distinct channel rows
The current version of the query can return duplicated rows. It aggregates
the data for distinct values of service_id.
@janbar @fetzerch janbar [mythtv-cmyth] Provide correct ids for merged channels
Channels are merged by the identifier (Number, CallSign). XBMC PVR therefore
only knows about the merged channels.

This adapts the timers and channel group members to always contain the channel
id of the merged channel.

Adds function FindPRVChannelUid() to return the merged channel id for channel.
@janbar @fetzerch janbar [mythtv-cmyth] Add demuxer
This adds the demuxer implementation.
The work is partially based on the VNSI demuxer.
@janbar @fetzerch janbar [mythtv-cmyth] Use demuxer in addon
Build the demuxer and use it in the addon.
New setting 'demuxing' in category 'advanced' allows to enable/disable the
@janbar @fetzerch janbar [mythtv-cmyth] Implement timeshift functions (PVR API 1.9.0)
- GetPlayingTime()
  Available only when using the internal MPEG-TS demuxer. Otherwise, return
  default value to PVR.

- GetBufferStartTime()
  Returns start time of first recording in the Live TV chain.

- GetBufferEndTime()
  Returns minimum of current time and end time of last recording in the Live TV
@fetzerch fetzerch [mythtv-cmyth] Wakeup the backend using Wake on LAN
If the backend's Ethernet address has been configured, the addon will
try to wakeup the backend in the following circumstances:

- On (re)connection
- When XBMC resumes from sleep
@janbar @fetzerch janbar [mythtv-cmyth] GetPIDStream: No need to find in the map 81b172c
@fetzerch fetzerch [cmyth] Fix signed/unsigned comparison warnings
file.c: In function 'cmyth_file_seek':
file.c:511:8: warning: comparison between signed and unsigned integer
    expressions [-Wsign-compare]
  if(c > sizeof(msg))

socket.c: In function '__cmyth_toupper_string':
socket.c:2996:17: warning: comparison between signed and unsigned
    integer expressions [-Wsign-compare]
  for ( i=0 ; i < sizeof(str) && str[i] != '\0' ; i++ ) {
@fetzerch fetzerch [cmyth] Fix variable set but not used warnings
mythtv_mysql.c: In function 'cmyth_mysql_get_recording_seek_offset':
mythtv_mysql.c:2323:10: warning: variable 'prev_mark' set but not used
 int64_t prev_mark = 0;

mythtv_mysql.c:2321:10: warning: variable 'next_mark' set but not used
  int64_t next_mark = 0;
@fetzerch fetzerch [cmyth] Fix declaration of cmyth_proginfo_syndicated_episode b6a24ab
@janbar @fetzerch janbar [cmyth] Implement cmyth_recorder_get_frames_written
Implement the previously empty stub cmyth_recorder_get_frames_written.
The function queries the number of frames the recorder has written to

Currently this function is implemented for protocol version >=66.
@janbar @fetzerch janbar [cmyth] Implement cmyth_recorder_get_keyframe_pos
This implements the previously empty function
cmyth_recorder_get_keyframe_pos. that queries the byte location of the
next key frame after the position given.

The function is currently implemented for backend version >=66.
@janbar @fetzerch janbar [cmyth] Implement cmyth_recorder_get_position_map
This implements the previously empty stub
cmyth_recorder_get_position_map that queries the position map from the

The function is currently implemented for backend version >=43.
@janbar @fetzerch janbar [cmyth] Implement cmyth_rcv_keyframe
This implements the previously empty stub for cmyth_rcv_keyframe.
The function reads a key frame from the socket.
@janbar @fetzerch janbar [cmyth] Add cmyth_rcv_posmap
Adds function cmyth_rcv_posmap. The function reads the position map
from the socket.
@janbar @fetzerch janbar [cmyth] Add cmyth_recorder_get_duration_map
This adds the function cmyth_recorder_get_duration_map that queries
the duration map from the backend.

The function is currently implemented for backend version >=77.
@janbar @fetzerch janbar [cmyth] Add cmyth_keyframe_number 0b2e3fc
@janbar @fetzerch janbar [cmyth] Add cmyth_keyframe_pos c7a76de
@janbar @fetzerch janbar [cmyth] Add cmyth_posmap_count f53ce9d
@janbar @fetzerch janbar [cmyth] Add cmyth_posmap_keyframe 506fc2c
@fetzerch fetzerch [cmyth] Win32: Fix compilation
Commit 079e538 broke compilation.
C89 requires that all variables are declared at the beginning of a
scope block.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' bd65761
@janbar @fetzerch janbar [mythtv-cmyth] Fix channel icon download with 0.27 backend
The default location is defined in the built-in ChannelIcons storage
group. When full path is specified then location is not considered by
the backend: This fix works with older backends.
@fetzerch fetzerch Merge remote-tracking branch 'upstream/master' 8c6d983
@janbar @fetzerch janbar [mythtv-cmyth] Handle extended TS streams: M2TS, ATSC 8-VSB, ISDB-T, …

- M2TS packet size is 192 bytes: 4B for timer + MTS packet
- ATSC 8-VSB packet size is 208: MTS packet + 20B for FEC
- ISDB-T packet size is 204: MTS packet + 16B for FEC
- DVB-T/C/S packet size is 204: MTS packet + 16B for FEC

At first sync it checks TS stream and selects packet size after
reaching the best score. Reached score varies from 2
(TS_CHECK_MIN_SCORE) to 10 packets (...MAX_SCORE), depending on
collisions (normal use 624 packets for QOS). Encapsulated TS packet is
not affected ans keep original size of 188 bytes. Once packet size is
discovered, function GoNext() will move to sync byte of next TS packet
and will discard unused data using selected size. Also it allows to
check stream at startup and break it if invalid returning
@janbar @fetzerch janbar [mythtv-cmyth] Cosmetics in elementaryStream.cpp 8facb5a
@janbar @fetzerch janbar [mythtv-cmyth] Add missing rule filter "This Channel" 51e9e77
@janbar @fetzerch janbar [mythtv-cmyth] Implement recording rules for MythTV 0.27
"Repeating" rules have to handle new behaviors based on filtering.

With EPG:
- Daily: "All record" + filter "This channel" & "This time"
- Weekly: "All record" + filter "This channel" & "This day and time"

Without EPG (custom):
-  Daily: "Daily" + filter "This channel"
- Weekly: "Weekly" + filter "This channel"

Refactor disabled rules "Channel record" & "One record" for future
usage as menu-hook by using a common interface with epgInfo as input.

Some rules cannot be implemented depending on the context.
For these cases the nil type is used (Not recording) and an attempt to
schedule such a recording will fail.

New virtual function GetMetadata() estimates rule metadata depending
of the backend version.
@janbar @fetzerch janbar [mythtv-cmyth] Use MythScheduleManager::GetMetadata() 6e377ac
@janbar @fetzerch janbar [cmyth] Add missing recording rule fields
Not null values for programid and seriesid are required for filtering.
Null values (not nil strings) fail DB SQL search.
@janbar @fetzerch janbar [mythtv-cmyth] Rules: Fix program filtering by programid and seriesid
Set programid and seriesid in recording rule to allow filtering by
@janbar @fetzerch janbar [mythtv-cmyth] Toggle show/hide not recording
Function MythScheduleManager::ToggleShowNotRecording() allows to enable
or disable visibility of 'not recording' rules.

This allows to implement a new hook to enable or disable visibility
and manage 'not recording' rules.
@janbar @fetzerch janbar [mythtv-cmyth] Manage special recording rules
Manage "Not recording" rules with PVR timer screen:
- Add setting menu hook "Show/Hide "Not recording" rules"

New functions to make and break a broadcast UID for program.

Create special recording rules:
- Add EPG menu hook "Record all showings (this channel)"
- Add EPG menu hook "Record this showing every week"
- Add EPG menu hook "Record this showing every day"
- Add EPG menu hook "Record one showing (all channels)"
- Add EPG menu hook "Record new episodes (this channel)"
@janbar @fetzerch janbar [mythtv-cmyth] Remove EPG gap correction
Not required since XBMC PR#3111 is merged.
Also it will allows to show gaps on EPG timeline grid with PR#3888.

Ignore this. I failed miserably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment