1 /* BlackMagic SDI driver */
8 #define INT64_C(c) c ## LL
11 #include <vlc_common.h>
12 #include <vlc_plugin.h>
13 #include <vlc_input.h>
14 #include <vlc_demux.h>
15 #include <vlc_access.h>
16 #include <vlc_picture.h>
17 #include <vlc_charset.h>
20 static int Open ( vlc_object_t * );
21 static void Close( vlc_object_t * );
23 #define CACHING_TEXT N_("Caching value in ms")
24 #define CACHING_LONGTEXT N_( \
25 "Caching value for SDI captures. This " \
26 "value should be set in milliseconds." )
29 set_shortname( N_("SDI") )
30 set_description( N_("BlackMagic SDI input") )
31 set_category( CAT_INPUT )
32 set_subcategory( SUBCAT_INPUT_ACCESS )
34 add_integer( "sdi-caching", DEFAULT_PTS_DELAY / 1000, NULL,
35 CACHING_TEXT, CACHING_LONGTEXT, true )
38 set_capability( "access_demux", 10 )
39 set_callbacks( Open, Close )
42 static int Demux ( demux_t * );
43 static int Control( demux_t *, int, va_list );
50 static int Open( vlc_object_t *p_this )
52 demux_t *p_demux = (demux_t*)p_this;
55 /* Only when selected */
56 if( *p_demux->psz_access == '\0' )
60 p_demux->pf_demux = Demux;
61 p_demux->pf_control = Control;
62 p_demux->info.i_update = 0;
63 p_demux->info.i_title = 0;
64 p_demux->info.i_seekpoint = 0;
65 p_demux->p_sys = p_sys = (demux_sys_t*)calloc( 1, sizeof( demux_sys_t ) );
69 msg_Dbg( p_demux, "hello world" );
71 /* Declare elementary streams */
73 es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_YUYV );
74 fmt.video.i_width = 720;
75 fmt.video.i_height = 576;
76 fmt.video.i_sar_num = 1;
77 fmt.video.i_sar_den = 1;
79 msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
80 (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );
81 p_sys->p_es = es_out_Add( p_demux->out, &fmt );
83 /* Update default_pts to a suitable value for access */
84 var_Create( p_demux, "sdi-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
89 static void Close( vlc_object_t *p_this )
91 demux_t *p_demux = (demux_t *)p_this;
92 demux_sys_t *p_sys = p_demux->p_sys;
97 static int Control( demux_t *p_demux, int i_query, va_list args )
104 /* Special for access_demux */
105 case DEMUX_CAN_PAUSE:
107 case DEMUX_CAN_CONTROL_PACE:
108 pb = (bool*)va_arg( args, bool * );
112 case DEMUX_GET_PTS_DELAY:
113 pi64 = (int64_t*)va_arg( args, int64_t * );
114 *pi64 = var_GetInteger( p_demux, "sdi-caching" ) * 1000;
118 pi64 = (int64_t*)va_arg( args, int64_t * );
119 *pi64 = mdate(); // FIXME
122 /* TODO implement others */
130 static int Demux( demux_t *p_demux )
132 demux_sys_t *p_sys = p_demux->p_sys;