2 * Copyright (C) 2004-2010, Eric Lund
3 * http://www.mvpmc.org/
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * keyframe.c - functions to manage key frame structures. Mostly
22 * just allocating, freeing, and filling them out.
24 #include <sys/types.h>
28 #include <cmyth_local.h>
31 * cmyth_keyframe_create(void)
37 * Create a key frame structure.
41 * Success: A non-NULL cmyth_keyframe_t (this type is a pointer)
43 * Failure: A NULL cmyth_keyframe_t
46 cmyth_keyframe_create(void)
48 cmyth_keyframe_t ret = ref_alloc(sizeof(*ret));
50 cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__);
52 cmyth_dbg(CMYTH_DBG_DEBUG, "%s } !\n", __FUNCTION__);
55 ret->keyframe_number = 0;
56 ret->keyframe_pos = 0;
57 cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__);
62 * cmyth_keyframe_fill(cmyth_keyframe_t kf,
63 * unsigned long keynum,
64 * unsigned long long pos)
70 * Fill out the contents of the recorder number structure 'rn' using
71 * the values 'keynum' and 'pos'.
80 cmyth_keyframe_fill(unsigned long keynum, unsigned long long pos)
82 cmyth_keyframe_t ret = cmyth_keyframe_create();
88 ret->keyframe_number = keynum;
89 ret->keyframe_pos = pos;
94 * cmyth_keyframe_string(cmyth_keyframe_t kf)
100 * Compose a MythTV protocol string from a keyframe structure and
101 * return a pointer to a malloc'ed buffer containing the string.
105 * Success: A non-NULL malloc'ed character buffer pointer.
110 cmyth_keyframe_string(cmyth_keyframe_t kf)
112 unsigned len = sizeof("[]:[]");
120 sprintf(pos, "%lld", kf->keyframe_pos);
122 sprintf(key, "%ld", kf->keyframe_number);
124 ret = malloc(len * sizeof(char));
129 strcat(ret, "[]:[]");