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 *****************************************************************************/
28 #include <vlc_common.h>
29 #include <vlc_plugin.h>
30 #include <vlc_access.h>
32 static int Open (vlc_object_t
*);
35 set_shortname (N_("SDP"))
36 set_description (N_("Session Description Protocol"))
37 set_category (CAT_INPUT
)
38 set_subcategory (SUBCAT_INPUT_ACCESS
)
40 set_capability ("access", 0)
41 set_callbacks (Open
, NULL
)
45 static ssize_t
Read (stream_t
*, void *, size_t);
46 static int Seek (stream_t
*, uint64_t);
47 static int Control (stream_t
*, int, va_list);
49 static int Open (vlc_object_t
*obj
)
51 stream_t
*access
= (stream_t
*)obj
;
53 access
->pf_read
= Read
;
54 access
->pf_block
= NULL
;
55 access
->pf_seek
= Seek
;
56 access
->pf_control
= Control
;
57 access
->p_sys
= (char *)access
->psz_location
;
62 static ssize_t
Read (stream_t
*access
, void *buf
, size_t len
)
64 char *in
= access
->p_sys
, *out
= buf
;
67 for (i
= 0; i
< len
&& *in
!= '\0'; i
++)
74 static int Seek (stream_t
*access
, uint64_t position
)
76 #if (UINT64_MAX > SIZE_MAX)
77 if (unlikely(position
> SIZE_MAX
))
80 access
->p_sys
= (char *)access
->psz_location
81 + strnlen(access
->psz_location
, position
);
85 static int Control (stream_t
*access
, int query
, va_list args
)
90 case STREAM_CAN_FASTSEEK
:
91 case STREAM_CAN_PAUSE
:
92 case STREAM_CAN_CONTROL_PACE
:
94 bool *b
= va_arg(args
, bool *);
100 *va_arg(args
, uint64_t *) = strlen(access
->psz_location
);
103 case STREAM_GET_PTS_DELAY
:
105 int64_t *dp
= va_arg(args
, int64_t *);
106 *dp
= DEFAULT_PTS_DELAY
;
110 case STREAM_SET_PAUSE_STATE
: