]> git.sesse.net Git - vlc/blobdiff - modules/access/decklink.cpp
Remove useless cast.
[vlc] / modules / access / decklink.cpp
index abefa5de51e3a977be349caa327e01d5f30c8597..aca08d5c9292bd174c3901724eebdfca75d5200f 100644 (file)
@@ -1,21 +1,35 @@
-/* Blackmagic SDI driver */
+/*****************************************************************************
+ * decklink.cpp: BlackMagic DeckLink SDI input module
+ *****************************************************************************
+ * Copyright (C) 2010 Steinar H. Gunderson
+ *
+ * Authors: Steinar H. Gunderson <steinar+vlc@gunderson.no>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *****************************************************************************/
+
+#define __STDC_CONSTANT_MACROS 1
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#ifndef INT64_C
-#define INT64_C(c) c ## LL
-#endif
-
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_input.h>
 #include <vlc_demux.h>
-#include <vlc_access.h>
-#include <vlc_picture.h>
-#include <vlc_charset.h>
-#include <vlc_fs.h>
 #include <vlc_atomic.h>
 
 #include <arpa/inet.h>
@@ -28,39 +42,39 @@ static void Close( vlc_object_t * );
 
 #define CARD_INDEX_TEXT N_("Input card to use")
 #define CARD_INDEX_LONGTEXT N_( \
-    "SDI capture card to use, if multiple exist. " \
+    "DeckLink capture card to use, if multiple exist. " \
     "The cards are numbered from 0." )
 
 #define MODE_TEXT N_("Desired input video mode")
 #define MODE_LONGTEXT N_( \
-    "Desired input video mode for SDI captures. " \
+    "Desired input video mode for DeckLink captures. " \
     "This value should be a FOURCC code in textual " \
     "form, e.g. \"ntsc\"." )
 
 #define CACHING_TEXT N_("Caching value in ms")
 #define CACHING_LONGTEXT N_( \
-    "Caching value for SDI captures. This " \
+    "Caching value for DeckLink captures. This " \
     "value should be set in milliseconds." )
 
 #define AUDIO_CONNECTION_TEXT N_("Audio connection")
 #define AUDIO_CONNECTION_LONGTEXT N_( \
-    "Audio connection to use for SDI captures. " \
+    "Audio connection to use for DeckLink captures. " \
     "Valid choices: embedded, aesebu, analog. " \
     "Leave blank for card default." )
 
 #define RATE_TEXT N_("Audio sampling rate in Hz")
 #define RATE_LONGTEXT N_( \
-    "Audio sampling rate (in hertz) for SDI captures. " \
+    "Audio sampling rate (in hertz) for DeckLink captures. " \
     "0 disables audio input." )
 
 #define CHANNELS_TEXT N_("Number of audio channels")
 #define CHANNELS_LONGTEXT N_( \
-    "Number of input audio channels for SDI captures. " \
+    "Number of input audio channels for DeckLink captures. " \
     "Must be 2, 8 or 16. 0 disables audio input." )
 
 #define VIDEO_CONNECTION_TEXT N_("Video connection")
 #define VIDEO_CONNECTION_LONGTEXT N_( \
-    "Video connection to use for SDI captures. " \
+    "Video connection to use for DeckLink captures. " \
     "Valid choices: sdi, hdmi, opticalsdi, component, " \
     "composite, svideo. " \
     "Leave blank for card default." )
@@ -70,8 +84,8 @@ static void Close( vlc_object_t * );
     "Aspect ratio (4:3, 16:9). Default assumes square pixels." )
 
 vlc_module_begin ()
-    set_shortname( N_("SDI") )
-    set_description( N_("Blackmagic SDI input") )
+    set_shortname( N_("DeckLink") )
+    set_description( N_("Blackmagic DeckLink SDI input") )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_ACCESS )
 
@@ -113,10 +127,8 @@ struct demux_sys_t
     bool b_first_frame;
     int i_last_pts;
 
-    int i_width, i_height, i_fps_num, i_fps_den;
     uint32_t i_dominance_flags;
-
-    int i_rate, i_channels;
+    int i_channels;
 
     vlc_mutex_t frame_lock;
     block_t *p_video_frame;  /* protected by <frame_lock> */
@@ -147,7 +159,12 @@ public:
         return new_ref;
     }
 
-    virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
+    virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags)
+    {
+        msg_Dbg( p_demux_, "Video input format changed" );
+        return S_OK;
+    }
+
     virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
 
 private:
@@ -155,12 +172,6 @@ private:
     demux_t *p_demux_;
 };
 
-HRESULT DeckLinkCaptureDelegate::VideoInputFormatChanged(BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode, BMDDetectedVideoInputFormatFlags)
-{
-    msg_Dbg( p_demux_, "Video input format changed" );
-    return S_OK;
-}
-
 HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame* videoFrame, IDeckLinkAudioInputPacket* audioFrame)
 {
     demux_sys_t *p_sys = p_demux_->p_sys;
@@ -192,7 +203,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
         for( int y = 0; y < i_height; ++y )
         {
             const uint8_t *src = (const uint8_t *)frame_bytes + i_stride * y;
-            uint8_t *dst = (uint8_t *)p_video_frame->p_buffer + i_width * i_bpp * y;
+            uint8_t *dst = p_video_frame->p_buffer + i_width * i_bpp * y;
             memcpy( dst, src, i_width * i_bpp );
         }
 
@@ -262,6 +273,8 @@ static int Open( vlc_object_t *p_this )
     char        *psz_audio_connection = NULL;
     bool        b_found_mode;
     int         i_card_index;
+    int         i_width, i_height, i_fps_num, i_fps_den;
+    int         i_rate;
 
     /* Only when selected */
     if( *p_demux->psz_access == '\0' )
@@ -492,10 +505,10 @@ static int Open( vlc_object_t *p_this )
         if( wanted_mode_id == mode_id )
         {
             b_found_mode = true;
-            p_sys->i_width = p_display_mode->GetWidth();
-            p_sys->i_height = p_display_mode->GetHeight();
-            p_sys->i_fps_num = time_scale;
-            p_sys->i_fps_den = frame_duration;
+            i_width = p_display_mode->GetWidth();
+            i_height = p_display_mode->GetHeight();
+            i_fps_num = time_scale;
+            i_fps_den = frame_duration;
             p_sys->i_dominance_flags = i_dominance_flags;
         }
 
@@ -520,11 +533,11 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* Set up audio. */
-    p_sys->i_rate = var_InheritInteger( p_demux, "decklink-audio-rate" );
     p_sys->i_channels = var_InheritInteger( p_demux, "decklink-audio-channels" );
-    if( p_sys->i_rate > 0 && p_sys->i_channels > 0 )
+    i_rate = var_InheritInteger( p_demux, "decklink-audio-rate" );
+    if( i_rate > 0 && p_sys->i_channels > 0 )
     {
-        result = p_sys->p_input->EnableAudioInput( p_sys->i_rate, bmdAudioSampleType16bitInteger, p_sys->i_channels );
+        result = p_sys->p_input->EnableAudioInput( i_rate, bmdAudioSampleType16bitInteger, p_sys->i_channels );
         if( result != S_OK )
         {
             msg_Err( p_demux, "Failed to enable audio input" );
@@ -548,12 +561,12 @@ static int Open( vlc_object_t *p_this )
     /* Declare elementary streams */
     es_format_t video_fmt;
     es_format_Init( &video_fmt, VIDEO_ES, VLC_CODEC_UYVY );
-    video_fmt.video.i_width = p_sys->i_width;
-    video_fmt.video.i_height = p_sys->i_height;
+    video_fmt.video.i_width = i_width;
+    video_fmt.video.i_height = i_height;
     video_fmt.video.i_sar_num = 1;
     video_fmt.video.i_sar_den = 1;
-    video_fmt.video.i_frame_rate = p_sys->i_fps_num;
-    video_fmt.video.i_frame_rate_base = p_sys->i_fps_den;
+    video_fmt.video.i_frame_rate = i_fps_num;
+    video_fmt.video.i_frame_rate_base = i_fps_den;
     video_fmt.i_bitrate = video_fmt.video.i_width * video_fmt.video.i_height * video_fmt.video.i_frame_rate * 2 * 8;
 
     psz_aspect = var_CreateGetNonEmptyString( p_demux, "decklink-aspect-ratio" );
@@ -576,7 +589,7 @@ static int Open( vlc_object_t *p_this )
     es_format_t audio_fmt;
     es_format_Init( &audio_fmt, AUDIO_ES, VLC_CODEC_S16N );
     audio_fmt.audio.i_channels = p_sys->i_channels;
-    audio_fmt.audio.i_rate = p_sys->i_rate;
+    audio_fmt.audio.i_rate = i_rate;
     audio_fmt.audio.i_bitspersample = 16;
     audio_fmt.audio.i_blockalign = audio_fmt.audio.i_channels * audio_fmt.audio.i_bitspersample / 8;
     audio_fmt.i_bitrate = audio_fmt.audio.i_channels * audio_fmt.audio.i_rate * audio_fmt.audio.i_bitspersample;