Exemplo n.º 1
0
cmyth_commbreaklist_t
cmyth_mysql_get_commbreaklist(cmyth_database_t db, cmyth_conn_t conn, cmyth_proginfo_t prog)
{
	cmyth_commbreaklist_t breaklist = cmyth_commbreaklist_create();
	char start_ts_dt[CMYTH_TIMESTAMP_LEN + 1];
	int r;

	cmyth_timestamp_to_display_string(start_ts_dt, prog->proginfo_rec_start_ts, 0);
	pthread_mutex_lock(&mutex);
	if ((r=cmyth_mysql_get_commbreak_list(db, prog->proginfo_chanId, start_ts_dt, breaklist, conn->conn_version)) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			"%s: cmyth_mysql_get_commbreak_list() failed (%d)\n",
			__FUNCTION__, r);
		goto out;
	}

	fprintf(stderr, "Found %li commercial breaks for current program.\n", breaklist->commbreak_count);
	if (r != breaklist->commbreak_count) {
		fprintf(stderr, "commbreak error.  Setting number of commercial breaks to zero\n");
		cmyth_dbg(CMYTH_DBG_ERROR, "%s  - returned rows=%d commbreak_count=%li\n",__FUNCTION__, r,breaklist->commbreak_count);
		breaklist->commbreak_count = 0;
	}
	out:
	pthread_mutex_unlock(&mutex);
	return breaklist;
}
Exemplo n.º 2
0
cmyth_commbreaklist_t
cmyth_get_cutlist(cmyth_conn_t conn, cmyth_proginfo_t prog)
{
	unsigned int len = CMYTH_UTC_LEN + CMYTH_LONGLONG_LEN + 17;
	int err;
	int count;
	char *buf;
	int r;

	cmyth_commbreaklist_t breaklist = cmyth_commbreaklist_create();

	buf = alloca(len);
	if (!buf) {
		return breaklist;
	}

	pthread_mutex_lock(&conn->conn_mutex);

	sprintf(buf,"%s %ld %i", "QUERY_CUTLIST", prog->proginfo_chanId, 
	        (int)cmyth_timestamp_to_unixtime(prog->proginfo_rec_start_ts));

	if ((err = cmyth_send_message(conn, buf)) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			"%s: cmyth_send_message() failed (%d)\n",
			__FUNCTION__, err);
		goto out;
	}

	count = cmyth_rcv_length(conn);
	if (count < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			"%s: cmyth_rcv_length() failed (%d)\n",
			__FUNCTION__, count);
		goto out;
	}

	if ((r = cmyth_rcv_commbreaklist(conn, &err, breaklist, count)) < 0) {
		cmyth_dbg(CMYTH_DBG_ERROR,
			"%s: cmyth_rcv_string() failed (%d)\n",
			__FUNCTION__, r);
		goto out;
	}

	out:
	pthread_mutex_unlock(&conn->conn_mutex);
	return breaklist;
}