Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for MythTV 0.25 in libcmyth #894

Merged
merged 10 commits into from
May 6, 2012
Merged
21 changes: 21 additions & 0 deletions lib/cmyth/include/cmyth/cmyth.h
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,20 @@ extern char *cmyth_proginfo_subtitle(cmyth_proginfo_t prog);
*/
extern char *cmyth_proginfo_description(cmyth_proginfo_t prog);

/**
* Retrieve the season of a program.
* \param prog proginfo handle
* \return season
*/
extern unsigned short cmyth_proginfo_season(cmyth_proginfo_t prog);

/**
* Retrieve the episode of a program.
* \param prog proginfo handle
* \return episode
*/
extern unsigned short cmyth_proginfo_episode(cmyth_proginfo_t prog);

/**
* Retrieve the category of a program.
* \param prog proginfo handle
Expand Down Expand Up @@ -804,6 +818,13 @@ extern char *cmyth_proginfo_seriesid(cmyth_proginfo_t prog);
*/
extern char *cmyth_proginfo_programid(cmyth_proginfo_t prog);

/**
* Retrieve the inetref of a program.
* \param prog proginfo handle
* \return null-terminated string
*/
extern char *cmyth_proginfo_inetref(cmyth_proginfo_t prog);

/**
* Retrieve the critics rating (number of stars) of a program.
* \param prog proginfo handle
Expand Down
19 changes: 15 additions & 4 deletions lib/cmyth/libcmyth/bookmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <errno.h>
#include <cmyth_local.h>

Expand Down Expand Up @@ -59,7 +60,7 @@ long long cmyth_get_bookmark(cmyth_conn_t conn, cmyth_proginfo_t prog)
}
if ((r=cmyth_rcv_long_long(conn, &err, &ll, count)) < 0) {
cmyth_dbg(CMYTH_DBG_ERROR,
"%s: cmyth_rcv_longlong() failed (%d)\n",
"%s: cmyth_rcv_long_long() failed (%d)\n",
__FUNCTION__, r);
ret = err;
goto out;
Expand All @@ -74,7 +75,7 @@ long long cmyth_get_bookmark(cmyth_conn_t conn, cmyth_proginfo_t prog)
int cmyth_set_bookmark(cmyth_conn_t conn, cmyth_proginfo_t prog, long long bookmark)
{
char *buf;
unsigned int len = CMYTH_TIMESTAMP_LEN + CMYTH_LONGLONG_LEN + 18;
unsigned int len = CMYTH_TIMESTAMP_LEN + CMYTH_LONGLONG_LEN * 2 + 18;
char resultstr[3];
int r,err;
int ret;
Expand All @@ -85,8 +86,18 @@ int cmyth_set_bookmark(cmyth_conn_t conn, cmyth_proginfo_t prog, long long bookm
if (!buf) {
return -ENOMEM;
}
sprintf(buf,"%s %ld %s %lld %lld","SET_BOOKMARK",prog->proginfo_chanId,
start_ts_dt, bookmark >> 32,(bookmark & 0xffffffff));
if (conn->conn_version >= 66) {
/*
* Since protocol 66 mythbackend expects a single 64 bit integer rather than two 32 bit
* hi and lo integers.
*/
sprintf(buf, "SET_BOOKMARK %ld %s %"PRIu64, prog->proginfo_chanId,
start_ts_dt, (int64_t)bookmark);
}
else {
sprintf(buf, "SET_BOOKMARK %ld %s %d %d", prog->proginfo_chanId,
start_ts_dt, (int32_t)(bookmark >> 32), (int32_t)(bookmark & 0xffffffff));
}
pthread_mutex_lock(&mutex);
if ((err = cmyth_send_message(conn,buf)) < 0) {
cmyth_dbg(CMYTH_DBG_ERROR,
Expand Down
3 changes: 3 additions & 0 deletions lib/cmyth/libcmyth/cmyth_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ struct cmyth_proginfo {
char *proginfo_title;
char *proginfo_subtitle;
char *proginfo_description;
unsigned short proginfo_season; /* new in V67 */
unsigned short proginfo_episode; /* new in V67 */
char *proginfo_category;
long proginfo_chanId;
char *proginfo_chanstr;
Expand Down Expand Up @@ -258,6 +260,7 @@ struct cmyth_proginfo {
char *proginfo_chan_output_filters; /* new in V8 */
char *proginfo_seriesid; /* new in V8 */
char *proginfo_programid; /* new in V12 */
char *proginfo_inetref; /* new in V67 */
cmyth_timestamp_t proginfo_lastmodified; /* new in V12 */
char *proginfo_stars; /* new in V12 */
cmyth_timestamp_t proginfo_originalairdate; /* new in V12 */
Expand Down
33 changes: 27 additions & 6 deletions lib/cmyth/libcmyth/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ static myth_protomap_t protomap[] = {
{62, "78B5631E"},
{63, "3875641D"},
{64, "8675309J"},
{65, "D2BB94C2"},
{66, "0C0FFEE0"},
{67, "0G0G0G0"},
{68, "90094EAD"},
{69, "63835135"},
{70, "53153836"},
{71, "05e82186"},
{72, "D78EFD6F"},
{73, "D7FE8D6F"},
{0, 0}
};

Expand Down Expand Up @@ -527,7 +536,7 @@ cmyth_conn_connect_file(cmyth_proginfo_t prog, cmyth_conn_t control,
int err = 0;
int count = 0;
int r;
int ann_size = sizeof("ANN FileTransfer []:[][]:[]");
int ann_size = sizeof("ANN FileTransfer 0[]:[][]:[]");
cmyth_file_t ret = NULL;

if (!prog) {
Expand Down Expand Up @@ -575,6 +584,12 @@ cmyth_conn_connect_file(cmyth_proginfo_t prog, cmyth_conn_t control,
myth_host, prog->proginfo_port, buflen);
goto shut;
}
/*
* Explicitly set the conn version to the control version as cmyth_connect() doesn't and some of
* the cmyth_rcv_* functions expect it to be the same as the protocol version used by mythbackend.
*/
conn->conn_version = control->conn_version;

ann_size += strlen(prog->proginfo_pathname) + strlen(my_hostname);
announcement = malloc(ann_size);
if (!announcement) {
Expand All @@ -584,7 +599,7 @@ cmyth_conn_connect_file(cmyth_proginfo_t prog, cmyth_conn_t control,
goto shut;
}
if (control->conn_version >= 44) {
sprintf(announcement, "ANN FileTransfer %s[]:[]%s[]:[]",
sprintf(announcement, "ANN FileTransfer %s 0[]:[]%s[]:[]", // write = false
my_hostname, prog->proginfo_pathname);
}
else {
Expand Down Expand Up @@ -631,7 +646,7 @@ cmyth_conn_connect_file(cmyth_proginfo_t prog, cmyth_conn_t control,
r = cmyth_rcv_u_long_long(conn, &err, &ret->file_length, count);
if (err) {
cmyth_dbg(CMYTH_DBG_ERROR,
"%s: (length) cmyth_rcv_longlong() failed (%d)\n",
"%s: (length) cmyth_rcv_u_long_long() failed (%d)\n",
__FUNCTION__, err);
goto shut;
}
Expand Down Expand Up @@ -683,7 +698,7 @@ cmyth_conn_connect_path(char* path, cmyth_conn_t control,
int err = 0;
int count = 0;
int r, port;
int ann_size = sizeof("ANN FileTransfer []:[][]:[]");
int ann_size = sizeof("ANN FileTransfer 0[]:[][]:[]");
struct sockaddr_in addr;
socklen_t addr_size = sizeof(addr);
cmyth_file_t ret = NULL;
Expand Down Expand Up @@ -716,6 +731,12 @@ cmyth_conn_connect_path(char* path, cmyth_conn_t control,
__FUNCTION__, host, port, buflen);
goto shut;
}
/*
* Explicitly set the conn version to the control version as cmyth_connect() doesn't and some of
* the cmyth_rcv_* functions expect it to be the same as the protocol version used by mythbackend.
*/
conn->conn_version = control->conn_version;

ann_size += strlen(path) + strlen(my_hostname);
announcement = malloc(ann_size);
if (!announcement) {
Expand All @@ -725,7 +746,7 @@ cmyth_conn_connect_path(char* path, cmyth_conn_t control,
goto shut;
}
if (control->conn_version >= 44) {
sprintf(announcement, "ANN FileTransfer %s[]:[]%s[]:[]",
sprintf(announcement, "ANN FileTransfer %s 0[]:[]%s[]:[]", // write = false
my_hostname, path);
}
else {
Expand Down Expand Up @@ -771,7 +792,7 @@ cmyth_conn_connect_path(char* path, cmyth_conn_t control,
r = cmyth_rcv_u_long_long(conn, &err, &ret->file_length, count);
if (err) {
cmyth_dbg(CMYTH_DBG_ERROR,
"%s: (length) cmyth_rcv_longlong() failed (%d)\n",
"%s: (length) cmyth_rcv_u_long_long() failed (%d)\n",
__FUNCTION__, err);
goto shut;
}
Expand Down
31 changes: 23 additions & 8 deletions lib/cmyth/libcmyth/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <inttypes.h>
#ifndef _MSC_VER
#include <sys/socket.h>
#endif
Expand Down Expand Up @@ -449,14 +450,28 @@ cmyth_file_seek(cmyth_file_t file, long long offset, int whence)

pthread_mutex_lock(&mutex);

snprintf(msg, sizeof(msg),
"QUERY_FILETRANSFER %ld[]:[]SEEK[]:[]%d[]:[]%d[]:[]%d[]:[]%d[]:[]%d",
file->file_id,
(int32_t)(offset >> 32),
(int32_t)(offset & 0xffffffff),
whence,
(int32_t)(file->file_pos >> 32),
(int32_t)(file->file_pos & 0xffffffff));
if (file->file_control->conn_version >= 66) {
/*
* Since protocol 66 mythbackend expects to receive a single 64 bit integer rather than
* two 32 bit hi and lo integers.
*/
snprintf(msg, sizeof(msg),
"QUERY_FILETRANSFER %ld[]:[]SEEK[]:[]%"PRIu64"[]:[]%d[]:[]%"PRIu64,
file->file_id,
(int64_t)offset,
whence,
(int64_t)file->file_pos);
}
else {
snprintf(msg, sizeof(msg),
"QUERY_FILETRANSFER %ld[]:[]SEEK[]:[]%d[]:[]%d[]:[]%d[]:[]%d[]:[]%d",
file->file_id,
(int32_t)(offset >> 32),
(int32_t)(offset & 0xffffffff),
whence,
(int32_t)(file->file_pos >> 32),
(int32_t)(file->file_pos & 0xffffffff));
}

if ((err = cmyth_send_message(file->file_control, msg)) < 0) {
cmyth_dbg(CMYTH_DBG_ERROR,
Expand Down
Loading