]> git.sesse.net Git - vlc/blob - modules/access/sdi.c
bcfa399aa5f0dc6c98703de56863229c3e050f7e
[vlc] / modules / access / sdi.c
1 /* BlackMagic SDI driver */
2
3 #ifdef HAVE_CONFIG_H
4 # include "config.h"
5 #endif
6
7 #include <vlc_common.h>
8 #include <vlc_plugin.h>
9 #include <vlc_input.h>
10 #include <vlc_demux.h>
11 #include <vlc_access.h>
12 #include <vlc_picture.h>
13 #include <vlc_charset.h>
14 #include <vlc_fs.h>
15
16 static int  Open ( vlc_object_t * );
17 static void Close( vlc_object_t * );
18
19 #define CACHING_TEXT N_("Caching value in ms")
20 #define CACHING_LONGTEXT N_( \
21     "Caching value for SDI captures. This " \
22     "value should be set in milliseconds." )
23
24 vlc_module_begin ()
25     set_shortname( N_("SDI") )
26     set_description( N_("BlackMagic SDI input") )
27     set_category( CAT_INPUT )
28     set_subcategory( SUBCAT_INPUT_ACCESS )
29
30     add_shortcut( "sdi" )
31     set_capability( "access_demux", 10 )
32     set_callbacks( Open, Close )
33 vlc_module_end ()
34
35 static int Demux  ( demux_t * );
36 static int Control( demux_t *, int, va_list );
37
38 struct demux_sys_t
39 {
40 };
41
42 static int Open( vlc_object_t *p_this )
43 {
44     demux_t     *p_demux = (demux_t*)p_this;
45     demux_sys_t *p_sys;
46
47     /* Only when selected */
48     if( *p_demux->psz_access == '\0' )
49         return VLC_EGENERIC;
50
51     /* Set up p_demux */
52     p_demux->pf_demux = Demux;
53     p_demux->pf_control = Control;
54     p_demux->info.i_update = 0;
55     p_demux->info.i_title = 0;
56     p_demux->info.i_seekpoint = 0;
57     p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
58     if( !p_sys )
59         return VLC_ENOMEM;
60
61     msg_Debug( p_demux, "hello world" );
62
63     /* Declare elementary streams */
64     es_format_t fmt;
65     es_format_Init( &fmt, VIDEO_ES, p_sys->i_fourcc );
66     fmt.video.i_width = 720;
67     fmt.video.i_height = 576;
68     fmt.video.i_sar_num = 1;
69     fmt.video.i_sar_den = 1;
70
71     msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
72              (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );
73     p_sys->p_es = es_out_Add( p_demux->out, &fmt );
74
75     /* Update default_pts to a suitable value for access */
76     var_Create( p_demux, "sdi-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
77
78     return VLC_SUCCESS;
79 }
80
81 static void Close( vlc_object_t *p_this )
82 {
83     demux_t     *p_demux = (demux_t *)p_this;
84     demux_sys_t *p_sys   = p_demux->p_sys;
85
86     free( p_sys );
87 }
88
89 static int Control( demux_t *p_demux, int i_query, va_list args )
90 {
91     bool *pb;
92     int64_t    *pi64;
93
94     switch( i_query )
95     {
96         /* Special for access_demux */
97         case DEMUX_CAN_PAUSE:
98         case DEMUX_CAN_SEEK:
99         case DEMUX_CAN_CONTROL_PACE:
100             pb = (bool*)va_arg( args, bool * );
101             *pb = false;
102             return VLC_SUCCESS;
103
104         case DEMUX_GET_PTS_DELAY:
105             pi64 = (int64_t*)va_arg( args, int64_t * );
106             *pi64 = var_GetInteger( p_demux, "sdi-caching" ) * 1000;
107             return VLC_SUCCESS;
108
109         case DEMUX_GET_TIME:
110             pi64 = (int64_t*)va_arg( args, int64_t * );
111             *pi64 = mdate();  // FIXME
112             return VLC_SUCCESS;
113
114         /* TODO implement others */
115         default:
116             return VLC_EGENERIC;
117     }
118
119     return VLC_EGENERIC;
120 }
121
122 static int Demux( demux_t *p_demux )
123 {
124     demux_sys_t *p_sys = p_demux->p_sys;
125
126     // FIXME
127
128     return 1;
129 }
130