1 /*****************************************************************************
2 * sdp.c: Fake input for sdp:// scheme
3 *****************************************************************************
4 * Copyright (C) 2010 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
25 #include <vlc_common.h>
26 #include <vlc_plugin.h>
27 #include <vlc_access.h>
29 static int Open (vlc_object_t *);
30 static void Close (vlc_object_t *);
33 set_shortname (N_("SDP"))
34 set_description (N_("Session Description Protocol"))
35 set_category (CAT_INPUT)
36 set_subcategory (SUBCAT_INPUT_ACCESS)
38 set_capability ("access", 0)
39 set_callbacks (Open, Close)
43 static ssize_t Read (access_t *, uint8_t *, size_t);
44 static int Seek (access_t *, uint64_t);
45 static int Control (access_t *, int, va_list);
53 static int Open (vlc_object_t *obj)
55 access_t *access = (access_t *)obj;
56 size_t len = strlen (access->psz_location);
58 access_sys_t *sys = malloc (sizeof(*sys) + len);
59 if (unlikely(sys == NULL))
62 /* NOTE: This copy is not really needed. Better safe than sorry. */
64 memcpy (sys->data, access->psz_location, len);
66 access_InitFields (access);
67 access->pf_read = Read;
68 access->pf_block = NULL;
69 access->pf_seek = Seek;
70 access->pf_control = Control;
76 static void Close (vlc_object_t *obj)
78 access_t *access = (access_t *)obj;
79 access_sys_t *sys = access->p_sys;
84 static ssize_t Read (access_t *access, uint8_t *buf, size_t len)
86 access_sys_t *sys = access->p_sys;
88 if (access->info.i_pos >= sys->length)
90 access->info.b_eof = true;
94 if (len > sys->length)
96 memcpy (buf, sys->data + access->info.i_pos, len);
97 access->info.i_pos += len;
101 static int Seek (access_t *access, uint64_t position)
103 access->info.i_pos = position;
104 access->info.b_eof = false;
108 static int Control (access_t *access, int query, va_list args)
112 case ACCESS_CAN_SEEK:
113 case ACCESS_CAN_FASTSEEK:
114 case ACCESS_CAN_PAUSE:
115 case ACCESS_CAN_CONTROL_PACE:
117 bool *b = va_arg(args, bool*);
122 case ACCESS_GET_PTS_DELAY:
124 int64_t *dp = va_arg(args, int64_t *);
125 *dp = DEFAULT_PTS_DELAY;
129 case ACCESS_SET_PAUSE_STATE: