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
*);
32 set_shortname (N_("SDP"))
33 set_description (N_("Session Description Protocol"))
34 set_category (CAT_INPUT
)
35 set_subcategory (SUBCAT_INPUT_ACCESS
)
37 set_capability ("access", 0)
38 set_callbacks (Open
, NULL
)
42 static ssize_t
Read (stream_t
*, void *, size_t);
43 static int Seek (stream_t
*, uint64_t);
44 static int Control (stream_t
*, int, va_list);
53 static int Open (vlc_object_t
*obj
)
55 stream_t
*access
= (stream_t
*)obj
;
56 size_t len
= strlen (access
->psz_location
);
58 access_sys_t
*sys
= vlc_malloc(obj
, sizeof(*sys
) + len
);
59 if (unlikely(sys
== NULL
))
62 /* NOTE: This copy is not really needed. Better safe than sorry. */
65 memcpy (sys
->data
, access
->psz_location
, len
);
67 access
->pf_read
= Read
;
68 access
->pf_block
= NULL
;
69 access
->pf_seek
= Seek
;
70 access
->pf_control
= Control
;
76 static ssize_t
Read (stream_t
*access
, void *buf
, size_t len
)
78 access_sys_t
*sys
= access
->p_sys
;
80 if (sys
->offset
>= sys
->length
)
83 if (len
> sys
->length
- sys
->offset
)
84 len
= sys
->length
- sys
->offset
;
85 memcpy (buf
, sys
->data
+ sys
->offset
, len
);
89 static int Seek (stream_t
*access
, uint64_t position
)
91 access_sys_t
*sys
= access
->p_sys
;
93 if (position
> sys
->length
)
94 position
= sys
->length
;
96 sys
->offset
= position
;
100 static int Control (stream_t
*access
, int query
, va_list args
)
102 access_sys_t
*sys
= access
->p_sys
;
106 case STREAM_CAN_SEEK
:
107 case STREAM_CAN_FASTSEEK
:
108 case STREAM_CAN_PAUSE
:
109 case STREAM_CAN_CONTROL_PACE
:
111 bool *b
= va_arg(args
, bool*);
116 case STREAM_GET_SIZE
:
117 *va_arg(args
, uint64_t *) = sys
->length
;
120 case STREAM_GET_PTS_DELAY
:
122 int64_t *dp
= va_arg(args
, int64_t *);
123 *dp
= DEFAULT_PTS_DELAY
;
127 case STREAM_SET_PAUSE_STATE
: