Support for MythTV 0.25 in libcmyth #894

Merged
merged 10 commits into from May 6, 2012
@@ -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
@@ -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
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <inttypes.h>
#include <errno.h>
#include <cmyth_local.h>
@@ -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;
@@ -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;
@@ -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,
@@ -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;
@@ -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 */
@@ -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}
};
@@ -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) {
@@ -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) {
@@ -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 {
@@ -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;
}
@@ -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;
@@ -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) {
@@ -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 {
@@ -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;
}
View
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include <inttypes.h>
#ifndef _MSC_VER
#include <sys/socket.h>
#endif
@@ -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,
Oops, something went wrong.