~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/access/dc1394.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 * dc1394.c: firewire input module
3
3
 *****************************************************************************
4
 
 * Copyright (C) 2006, the VideoLAN team
 
4
 * Copyright (C) 2006 the VideoLAN team
5
5
 *
6
6
 * Authors: Xant Majere <xant@xant.net>
7
7
 *
26
26
 * Preamble
27
27
 *****************************************************************************/
28
28
 
29
 
#include <vlc/vlc.h>
30
 
#include <vlc/input.h>
31
 
#include <vlc/vout.h>
32
 
 
33
 
#include <stdio.h>
34
 
#include <stdlib.h>
35
 
#include <string.h>
 
29
#ifdef HAVE_CONFIG_H
 
30
# include "config.h"
 
31
#endif
 
32
 
 
33
#include <vlc_common.h>
 
34
#include <vlc_plugin.h>
 
35
#include <vlc_input.h>
 
36
#include <vlc_vout.h>
 
37
#include <vlc_demux.h>
 
38
 
36
39
 
37
40
#ifdef HAVE_FCNTL_H
38
41
#   include <fcntl.h>
61
64
static inline void CloseAudioDev( demux_t *p_demux );
62
65
 
63
66
vlc_module_begin();
64
 
    set_description( _("dc1394 input") );
 
67
    set_description( N_("dc1394 input") );
65
68
    set_capability( "access_demux", 10 );
66
69
    add_shortcut( "dc1394" );
67
70
    set_callbacks( Open, Close );
87
90
    u_int64_t           selected_uid;
88
91
 
89
92
    dc_camera           *camera_nodes;
90
 
        dc1394_camerainfo   camera_info;
91
 
        dc1394_miscinfo     misc_info;
 
93
    dc1394_camerainfo   camera_info;
 
94
    dc1394_miscinfo     misc_info;
92
95
    raw1394handle_t     fd_video;
93
96
    quadlet_t           supported_framerates;
94
97
 
107
110
    int                 i_audio_max_frame_size;
108
111
    int                 fd_audio;
109
112
    char                *audio_device;
110
 
    int                 rotate;
111
113
#define NO_ROTATION 0
112
114
#define ROTATION_LEFT 1
113
115
#define ROTATION_RIGHT 2
126
128
/*****************************************************************************
127
129
 * ScanCameras
128
130
 *****************************************************************************/
129
 
static int ScanCameras( dc1394_sys *sys, demux_t *p_demux )
 
131
static void ScanCameras( dc1394_sys *sys, demux_t *p_demux )
130
132
{
131
133
    struct raw1394_portinfo portinfo[MAX_IEEE1394_HOSTS];
132
134
    raw1394handle_t tempFd;
133
135
    dc1394_camerainfo  info;
134
 
    dc_camera       *node_list = NULL;
135
 
    nodeid_t        *nodes = NULL;
 
136
    dc_camera *node_list = NULL;
 
137
    nodeid_t  *nodes = NULL;
136
138
    int num_ports = 0;
137
139
    int num_cameras = 0;
138
140
    int nodecount;
158
160
        tempFd = dc1394_create_handle( i );
159
161
 
160
162
        /* skip this port if we can't obtain a valid handle */
161
 
        if(!tempFd)
 
163
        if( !tempFd )
162
164
            continue;
163
165
        msg_Dbg( p_demux, "Found ieee1394 port %d (%s) ... "
164
166
                          "checking for camera nodes",
171
173
            msg_Dbg( p_demux, "Found %d dc1394 cameras on port %d (%s)",
172
174
                     nodecount, i, portinfo[i].name );
173
175
 
174
 
            if(node_list)
 
176
            if( node_list )
175
177
                node_list = realloc( node_list, sizeof(dc_camera) * (num_cameras+nodecount) );
176
178
            else
177
179
                node_list = malloc( sizeof(dc_camera) * nodecount);
192
194
        }
193
195
        else
194
196
            msg_Dbg( p_demux, "no cameras found  on port %d (%s)",
195
 
                     i, portinfo[i].name);
 
197
                     i, portinfo[i].name );
196
198
 
197
 
        if(tempFd)
 
199
        if( tempFd )
198
200
            dc1394_destroy_handle( tempFd );
199
201
    }
200
202
    sys->num_ports = num_ports;
201
203
    sys->num_cameras = num_cameras;
202
204
    sys->camera_nodes = node_list;
203
 
    return VLC_SUCCESS;
204
205
}
205
206
 
206
207
/*****************************************************************************
226
227
 
227
228
    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
228
229
    if( !p_sys )
229
 
    {
230
 
        msg_Err( p_demux, "not enough memory available" );
231
230
        return VLC_ENOMEM;
232
 
    }
233
231
    memset( p_sys, 0, sizeof( demux_sys_t ) );
234
232
    memset( &fmt, 0, sizeof( es_format_t ) );
235
233
 
247
245
    p_sys->selected_camera = 0;
248
246
    p_sys->dma_device = NULL;
249
247
    p_sys->selected_uid = 0;
250
 
    p_sys->rotate = NO_ROTATION;
251
248
 
252
249
    /* PROCESS INPUT OPTIONS */
253
250
    if( process_options(p_demux) != VLC_SUCCESS )
267
264
    if( !p_sys->camera_nodes )
268
265
    {
269
266
        msg_Err( p_demux, "No camera found !!" );
270
 
        Close( p_this );
 
267
        free( p_sys );
 
268
        p_demux->p_sys = NULL;
271
269
        return VLC_EGENERIC;
272
270
    }
273
271
 
474
472
    /* TODO - UYV444 chroma converter is missing, when it will be available
475
473
     * fourcc will become variable (and not just a fixed value for UYVY)
476
474
     */
477
 
    if( p_sys->rotate == NO_ROTATION )
478
 
    {
479
 
        i_width = p_sys->camera.frame_width;
480
 
        i_height = p_sys->camera.frame_height;
481
 
    }
482
 
    else
483
 
    {
484
 
        i_width = p_sys->camera.frame_height;
485
 
        i_height = p_sys->camera.frame_width;
486
 
    }
 
475
    i_width = p_sys->camera.frame_width;
 
476
    i_height = p_sys->camera.frame_height;
487
477
 
488
478
    i_aspect = vout_InitPicture( VLC_OBJECT(p_demux), &p_sys->pic,
489
479
                    VLC_FOURCC('U', 'Y', 'V', 'Y'),
580
570
    result = ioctl( p_sys->fd_audio, SNDCTL_DSP_SPEED, &p_sys->i_sample_rate );
581
571
    if( result < 0 )
582
572
    {
583
 
        msg_Err( p_demux, "cannot set audio sample rate (%d)",
584
 
                 p_sys->i_sample_rate );
 
573
        msg_Err( p_demux, "cannot set audio sample rate (%s)", p_sys->i_sample_rate );
585
574
        CloseAudioDev( p_demux );
586
575
    }
587
576
 
637
626
        dc1394_destroy_handle( p_sys->fd_video );
638
627
    CloseAudioDev( p_demux );
639
628
 
640
 
    if( p_sys->camera_nodes )
641
 
        free( p_sys->camera_nodes );
642
 
    if( p_sys->audio_device )
643
 
        free( p_sys->audio_device );
 
629
    free( p_sys->camera_nodes );
 
630
    free( p_sys->audio_device );
644
631
 
645
632
    free( p_sys );
646
633
}
721
708
        return NULL;
722
709
    }
723
710
 
724
 
    if( p_sys->rotate == NO_ROTATION )
725
 
    {
726
 
        memcpy( p_block->p_buffer, (const char *)p_sys->camera.capture_buffer,
727
 
                p_sys->camera.frame_width * p_sys->camera.frame_height * 2 );
728
 
    }
729
 
    else
730
 
    {
731
 
        int index = 0;
732
 
        int offset = 0;
733
 
        int i = 0, k = 0;
734
 
 
735
 
        /* rotate UYVY image */
736
 
        if( p_sys->rotate == ROTATION_LEFT )
737
 
        {
738
 
            for( i = p_sys->width-1; i >= 0; i-- )
739
 
            {
740
 
                for( k = 0; k < p_sys->height; k++ )
741
 
                {
742
 
                    index = (k * p_sys->width) + i;
743
 
                    MovePixelUYVY( p_sys->camera.capture_buffer, index,
744
 
                                   p_block->p_buffer, offset );
745
 
                    offset++;
746
 
                }
747
 
            }
748
 
        }
749
 
        else
750
 
        { /* ROTATION RIGHT */
751
 
            for( i = 0; i < p_sys->width; i++ )
752
 
            {
753
 
                for( k = p_sys->height-1; k >= 0; k-- )
754
 
                {
755
 
                    index = (k * p_sys->width) + i;
756
 
                    MovePixelUYVY( p_sys->camera.capture_buffer, index,
757
 
                                   p_block->p_buffer, offset );
758
 
                    offset++;
759
 
                }
760
 
            }
761
 
        }
762
 
    }
 
711
    memcpy( p_block->p_buffer, (const char *)p_sys->camera.capture_buffer,
 
712
            p_sys->camera.frame_width * p_sys->camera.frame_height * 2 );
763
713
 
764
714
    p_block->i_pts = p_block->i_dts = mdate();
765
715
    if( p_sys->dma_capture )
798
748
        i_correct += buf_info.bytes;
799
749
 
800
750
    p_block->i_pts = p_block->i_dts =
801
 
                        mdate() - I64C(1000000) * (mtime_t)i_correct /
 
751
                        mdate() - INT64_C(1000000) * (mtime_t)i_correct /
802
752
                        2 / p_sys->channels / p_sys->i_sample_rate;
803
753
    return p_block;
804
754
}
845
795
 *****************************************************************************/
846
796
static int Control( demux_t *p_demux, int i_query, va_list args )
847
797
{
848
 
    vlc_bool_t *pb;
 
798
    bool *pb;
849
799
    int64_t    *pi64;
850
800
 
851
801
    switch( i_query )
852
802
    {
853
803
        /* Special for access_demux */
854
804
        case DEMUX_CAN_PAUSE:
 
805
        case DEMUX_CAN_SEEK:
855
806
        case DEMUX_SET_PAUSE_STATE:
856
807
        case DEMUX_CAN_CONTROL_PACE:
857
 
            pb = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
858
 
            *pb = VLC_FALSE;
 
808
            pb = (bool*)va_arg( args, bool * );
 
809
            *pb = false;
859
810
            return VLC_SUCCESS;
860
811
 
861
812
        case DEMUX_GET_PTS_DELAY:
878
829
static int process_options( demux_t *p_demux )
879
830
{
880
831
    demux_sys_t *p_sys = p_demux->p_sys;
881
 
    char *psz_dup; 
 
832
    char *psz_dup;
882
833
    char *psz_parser;
883
834
    char *token = NULL;
884
835
    char *state = NULL;
885
836
    float rate_f;
886
837
 
887
 
    if( strncmp(p_demux->psz_access,"dc1394",6) != 0 )
 
838
    if( strncmp(p_demux->psz_access, "dc1394", 6) != 0 )
888
839
        return VLC_EGENERIC;
889
840
 
890
841
    psz_dup = strdup( p_demux->psz_path );
904
855
                    "video size of 160x120 is actually disabled for lack of chroma "
905
856
                    "support. It will relased ASAP, until then try an higher size "
906
857
                    "(320x240 and 640x480 are fully supported)" );
907
 
                free(psz_dup);
 
858
                free( psz_dup );
908
859
                return VLC_EGENERIC;
909
860
#if 0
910
861
                p_sys->frame_size = MODE_160x120_YUV444;
931
882
                    " 160x120, 320x240, and 640x480. "
932
883
                    "Please specify one of them. You have specified %s.",
933
884
                    token );
934
 
                free(psz_dup);
 
885
                free( psz_dup );
935
886
                return VLC_EGENERIC;
936
887
            }
937
888
            msg_Dbg( p_demux, "Requested video size : %s",token );
959
910
                    " 1.875, 3.75, 7.5, 15, 30, 60. "
960
911
                    "Please specify one of them. You have specified %s.",
961
912
                    token);
962
 
                free(psz_dup);
 
913
                free( psz_dup );
963
914
                return VLC_EGENERIC;
964
915
            }
965
916
            msg_Dbg( p_demux, "Requested frame rate : %s",token );
974
925
                msg_Err( p_demux, "Bad brightness value '%s', "
975
926
                                  "must be an unsigned integer.",
976
927
                                  token );
977
 
                free(psz_dup);
 
928
                free( psz_dup );
978
929
                return VLC_EGENERIC;
979
930
            }
980
931
        }
1003
954
                msg_Err( p_demux, "Bad camera number '%s', "
1004
955
                                  "must be an unsigned integer.",
1005
956
                                  token );
1006
 
                free(psz_dup);
 
957
                free( psz_dup );
1007
958
                return VLC_EGENERIC;
1008
959
            }
1009
960
        }
1025
976
                msg_Err(p_demux, "Bad capture method value '%s', "
1026
977
                                 "it can be 'raw1394' or 'video1394'.",
1027
978
                                token );
1028
 
                free(psz_dup);
 
979
                free( psz_dup );
1029
980
                return VLC_EGENERIC;
1030
981
            }
1031
982
        }
1055
1006
            token += strlen("uid=");
1056
1007
            sscanf( token, "0x%llx", &p_sys->selected_uid );
1057
1008
        }
1058
 
        else if( strncmp( token, "rotate=", strlen( "rotate=" ) ) == 0)
1059
 
        {
1060
 
            token += strlen("rotate=");
1061
 
            if( strncmp( token, "left", 4) == 0 )
1062
 
            {
1063
 
                msg_Dbg( p_demux, "Left Rotation enabled" );
1064
 
                p_sys->rotate = ROTATION_LEFT;
1065
 
            }
1066
 
            else if( strncmp( token, "right", 5 ) == 0 )
1067
 
            {
1068
 
                msg_Dbg( p_demux, "Right Rotation enabled" );
1069
 
                p_sys->rotate = ROTATION_RIGHT;
1070
 
            }
1071
 
            else
1072
 
            {
1073
 
                msg_Err( p_demux, "Bad rotation value '%s', "
1074
 
                                  "it can be 'left' or 'right'.",
1075
 
                                  token);
1076
 
                free(psz_dup);
1077
 
                return VLC_EGENERIC;
1078
 
            }
1079
 
        }
1080
1009
    }
1081
 
    if( psz_dup ) free( psz_dup );
 
1010
    free( psz_dup );
1082
1011
    return VLC_SUCCESS;
1083
1012
}
 
1013