chromecast: lower vorbis encoding quality
[vlc.git] / modules / access / sdp.c
blobfc7efa3fc4a307a17d920dec8789fbc878cd3f26
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 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <limits.h>
26 #include <string.h>
28 #include <vlc_common.h>
29 #include <vlc_plugin.h>
30 #include <vlc_access.h>
32 static int Open (vlc_object_t *);
34 vlc_module_begin ()
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)
42 add_shortcut ("sdp")
43 vlc_module_end()
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;
59 return VLC_SUCCESS;
62 static ssize_t Read (stream_t *access, void *buf, size_t len)
64 char *in = access->p_sys, *out = buf;
65 size_t i;
67 for (i = 0; i < len && *in != '\0'; i++)
68 *(out++) = *(in++);
70 access->p_sys = in;
71 return i;
74 static int Seek (stream_t *access, uint64_t position)
76 #if (UINT64_MAX > SIZE_MAX)
77 if (unlikely(position > SIZE_MAX))
78 position = SIZE_MAX;
79 #endif
80 access->p_sys = (char *)access->psz_location
81 + strnlen(access->psz_location, position);
82 return VLC_SUCCESS;
85 static int Control (stream_t *access, int query, va_list args)
87 switch (query)
89 case STREAM_CAN_SEEK:
90 case STREAM_CAN_FASTSEEK:
91 case STREAM_CAN_PAUSE:
92 case STREAM_CAN_CONTROL_PACE:
94 bool *b = va_arg(args, bool *);
95 *b = true;
96 return VLC_SUCCESS;
99 case STREAM_GET_SIZE:
100 *va_arg(args, uint64_t *) = strlen(access->psz_location);
101 return VLC_SUCCESS;
103 case STREAM_GET_PTS_DELAY:
105 int64_t *dp = va_arg(args, int64_t *);
106 *dp = DEFAULT_PTS_DELAY;
107 return VLC_SUCCESS;
110 case STREAM_SET_PAUSE_STATE:
111 return VLC_SUCCESS;
113 return VLC_EGENERIC;