From 42beaa5f189a978f8a4a7d749bb56e2c6dea5ebb Mon Sep 17 00:00:00 2001 From: Niels Elburg Date: Mon, 21 Feb 2005 19:03:54 +0000 Subject: [PATCH] added channel support to dv1394 git-svn-id: svn://code.dyne.org/veejay/trunk@199 eb8d1916-c9e9-0310-b8de-cf0c9472ead5 --- veejay-current/ChangeLog | 8 ++--- veejay-current/README.quickstart | 16 +++++++++ veejay-current/libstream/vj-dv1394.c | 14 ++++++-- veejay-current/libstream/vj-dv1394.h | 2 +- veejay-current/libstream/vj-tag.c | 54 ++++++++++++++-------------- veejay-current/veejay/liblavplayvj.c | 2 +- veejay-current/veejay/vj-event.c | 34 ++++++++++-------- 7 files changed, 79 insertions(+), 51 deletions(-) diff --git a/veejay-current/ChangeLog b/veejay-current/ChangeLog index e4f0cda0..922fc72a 100644 --- a/veejay-current/ChangeLog +++ b/veejay-current/ChangeLog @@ -20,10 +20,10 @@ + librified editlist,stream and yuv functions + removed any references on dropped vloopback support + fixed ticket 6 - - - fixed ticket 7 - - - autosplit? + + fixed ticket 7 + + fixed autosplitting while recording + + added dv1394 stream support + (uses libdv, so its slow even on a pentium3/1 ghz) 0.7.1 + fixed color corruption in fib diff --git a/veejay-current/README.quickstart b/veejay-current/README.quickstart index b311368e..d39b7a1d 100644 --- a/veejay-current/README.quickstart +++ b/veejay-current/README.quickstart @@ -95,4 +95,20 @@ Or in veejay's console (activate a stream or clip and) press SHIFT+S or SHIFT+B or SHIFT+ ... +Except all that, try this: + + +sayVIMS -h localhost -p 3490 "145:;" +(press F7) + +to open your dv1394 firewire device + +or +sayVIMS -h localhost -p 3490 "144:0 1;" +(press F7) + +to open your video4linux device /dev/video0, channel 1 + + + Enjoy! diff --git a/veejay-current/libstream/vj-dv1394.c b/veejay-current/libstream/vj-dv1394.c index 95ea48a9..c3e56ec1 100644 --- a/veejay-current/libstream/vj-dv1394.c +++ b/veejay-current/libstream/vj-dv1394.c @@ -38,7 +38,7 @@ #define DV1394_DEFAULT_CARD 0 #define DV1394_RING_FRAMES 2 -static int vj_dv1394_reset(vj_dv1394 *v ) +static int vj_dv1394_reset(vj_dv1394 *v ) { struct dv1394_init init; init.channel = v->channel; @@ -66,9 +66,17 @@ static int vj_dv1394_start(vj_dv1394 *v ) return 1; } -vj_dv1394 *vj_dv1394_init(void *e) +vj_dv1394 *vj_dv1394_init(void *e, int channel) { editlist *el = (editlist*)e; + + if(el->video_width != 720 && ( el->video_height != 576 || el->video_height != 480) ) + { + veejay_msg(VEEJAY_MSG_ERROR, "No software scaling to %d x %d",el->video_width, + el->video_height); + return NULL; + } + vj_dv1394 *v = (vj_dv1394*)vj_malloc(sizeof(vj_dv1394)); v->map_size = (el->video_norm == 'p' ? DV_PAL_SIZE: DV_NTSC_SIZE); @@ -77,7 +85,7 @@ vj_dv1394 *vj_dv1394_init(void *e) v->height = el->video_height; v->norm = (el->video_norm == 'p' ? DV1394_PAL: DV1394_NTSC ); v->handle = open( "/dev/dv1394", O_RDONLY); - v->channel = DV1394_DEFAULT_CHANNEL; + v->channel = channel == -1 ? DV1394_DEFAULT_CHANNEL : channel; v->index = 0; if( v->handle == -1 ) { diff --git a/veejay-current/libstream/vj-dv1394.h b/veejay-current/libstream/vj-dv1394.h index 9816e2c1..6c042ef8 100644 --- a/veejay-current/libstream/vj-dv1394.h +++ b/veejay-current/libstream/vj-dv1394.h @@ -36,7 +36,7 @@ typedef struct void *decoder; } vj_dv1394; -vj_dv1394* vj_dv1394_init(void *el); +vj_dv1394* vj_dv1394_init(void *el, int channel_nr); void vj_dv1394_close( vj_dv1394 *v ); diff --git a/veejay-current/libstream/vj-tag.c b/veejay-current/libstream/vj-tag.c index abefb48e..c64af29d 100644 --- a/veejay-current/libstream/vj-tag.c +++ b/veejay-current/libstream/vj-tag.c @@ -344,9 +344,10 @@ int _vj_tag_new_yuv4mpeg(vj_tag * tag, int stream_nr, editlist * el) return 1; } -int _vj_tag_new_dv1394(vj_tag *tag, int stream_nr, editlist *el) +int _vj_tag_new_dv1394(vj_tag *tag, int stream_nr, int channel, editlist *el) { - vj_tag_input->dv1394[0] = vj_dv1394_init( (void*) el); + vj_tag_input->dv1394[0] = vj_dv1394_init( (void*) el, channel); + veejay_msg(VEEJAY_MSG_DEBUG, "Channel in stream %d",channel); if(vj_tag_input->dv1394[0]) { veejay_msg(VEEJAY_MSG_INFO, "DV1394 ready for capture"); @@ -375,32 +376,35 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el, } n = this_tag_id; /* see if we are already using the source */ - for (i = 1; i < n; i++) { - if (vj_tag_exists(i)) { - vj_tag_get_source_name(i, sourcename); - if (strcmp(sourcename, filename) == 0) { - vj_tag *tt = vj_tag_get( i ); - if( tt->source_type == VJ_TAG_TYPE_NET || tt->source_type == VJ_TAG_TYPE_MCAST ) + for (i = 1; i < n; i++) + { + if (vj_tag_exists(i)) { - if( tt->video_channel == channel ) + vj_tag_get_source_name(i, sourcename); + if (strcmp(sourcename, filename) == 0) { + vj_tag *tt = vj_tag_get( i ); + if( tt->source_type == VJ_TAG_TYPE_NET || tt->source_type == VJ_TAG_TYPE_MCAST ) { - veejay_msg(VEEJAY_MSG_WARNING, "Already streaming from %s:%p in stream %d", - filename,channel, tt->id); + if( tt->video_channel == channel ) + { + veejay_msg(VEEJAY_MSG_WARNING, "Already streaming from %s:%p in stream %d", + filename,channel, tt->id); + return -1; + } + } + else + { + veejay_msg(VEEJAY_MSG_WARNING, + "Stream [%d] is already owner of file [%s]\n", n, + filename); return -1; } - } - else - { - veejay_msg(VEEJAY_MSG_WARNING, - "Stream [%d] is already owner of file [%s]\n", n, - filename); - return -1; - } } - } + } } tag = (vj_tag *) vj_malloc(sizeof(vj_tag)); - + if(!tag) + return -1; tag->source_name = (char *) malloc(sizeof(char) * 255); if (!tag->source_name) return -1; @@ -482,7 +486,7 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el, break; case VJ_TAG_TYPE_DV1394: sprintf(tag->source_name, "/dev/dv1394"); - if( _vj_tag_new_dv1394( tag, 0,el ) == 0 ) + if( _vj_tag_new_dv1394( tag, 0,channel,el ) == 0 ) { veejay_msg(VEEJAY_MSG_ERROR, "error opening dv1394"); return -1; @@ -882,9 +886,6 @@ static int vj_tag_start_encoder(vj_tag *tag, int format, long nframes) ); - veejay_msg(VEEJAY_MSG_DEBUG, "sf = %ld , tf = %ld , nframes = %ld, duration = %ld", - tag->encoder_succes_frames,tag->encoder_total_frames,nframes,tag->encoder_duration ); - if(!tag->encoder_file) { veejay_msg(VEEJAY_MSG_ERROR,"Cannot write to %s (%s)",tag->encoder_destination, @@ -1759,9 +1760,6 @@ int vj_tag_record_frame(int t1, uint8_t *buffer[3], uint8_t *abuff, int audio_si if(lav_write_frame(tag->encoder_file, tag_encoder_buf, buf_len,1)) { veejay_msg(VEEJAY_MSG_ERROR, "writing frame, giving up :[%s]", lav_strerror()); - veejay_msg(VEEJAY_MSG_DEBUG, "tb = %ld, tf = %ld, sf = %ld , dur = %ld", - tag->rec_total_bytes + buf_len, tag->encoder_total_frames, - tag->encoder_succes_frames, tag->encoder_duration); return -1; } tag->rec_total_bytes += buf_len; diff --git a/veejay-current/veejay/liblavplayvj.c b/veejay-current/veejay/liblavplayvj.c index 24a83302..17fef6d9 100644 --- a/veejay-current/veejay/liblavplayvj.c +++ b/veejay-current/veejay/liblavplayvj.c @@ -895,7 +895,7 @@ int veejay_create_tag(veejay_t * info, int type, char *filename, } break; case VJ_TAG_TYPE_DV1394: - if(vj_tag_new(type, filename, index,info->edit_list, info->pixel_format, 0) ) + if(vj_tag_new(type, filename, index,info->edit_list, info->pixel_format, channel) ) { veejay_msg(VEEJAY_MSG_DEBUG, "Created new DV1394 stream"); info->nstreams++; diff --git a/veejay-current/veejay/vj-event.c b/veejay-current/veejay/vj-event.c index 3e8f5748..cb774087 100644 --- a/veejay-current/veejay/vj-event.c +++ b/veejay-current/veejay/vj-event.c @@ -756,7 +756,7 @@ static struct { #ifdef HAVE_V4L { VJ_EVENT_TAG_NEW_V4L, "Stream: open video4linux device (hw)", vj_event_tag_new_v4l, 2, "%d %d", {0,1} }, #endif - { VJ_EVENT_TAG_NEW_DV1394, "Stream: open dv1394 device", vj_event_tag_new_dv1394, 0, NULL,{0,0} }, + { VJ_EVENT_TAG_NEW_DV1394, "Stream: open dv1394 device ", vj_event_tag_new_dv1394, 1, "%d",{63,0} }, { VJ_EVENT_TAG_NEW_Y4M, "Stream: open y4m stream by name (file)", vj_event_tag_new_y4m, 1, "%s", {0,0} }, { VJ_EVENT_STREAM_NEW_NET, "Stream: open network stream ", vj_event_tag_new_net, 2, "%s %d", {0,0} }, { VJ_EVENT_STREAM_NEW_MCAST, "Stream: open multicast stream", vj_event_tag_new_mcast, 2, "%s %d", {0,0} }, @@ -1509,7 +1509,7 @@ void vj_event_parse_msg(veejay_t *v, char *msg) less expansive. */ - if ( vj_event_list[id].format[1] == 's' ) + if ( vj_event_list[id].format != NULL && vj_event_list[id].format[1] == 's' ) { vj_event_trigger_function( (void*)v, @@ -5283,17 +5283,23 @@ void vj_event_tag_new_avformat(void *ptr, const char format[], va_list ap) int *args = NULL; P_A(args,str,format,ap); - if( veejay_create_tag(v, VJ_TAG_TYPE_AVFORMAT, str, v->nstreams,0,0) == 0) + if( veejay_create_tag(v, VJ_TAG_TYPE_AVFORMAT, str, v->nstreams,0,0) != 0) { - veejay_msg(VEEJAY_MSG_INFO, "Created new FFmpeg stream %d", vj_tag_size()-1); + veejay_msg(VEEJAY_MSG_INFO, "Unable to create new FFmpeg stream"); } } void vj_event_tag_new_dv1394(void *ptr, const char format[], va_list ap) { veejay_t *v = (veejay_t*)ptr; - if( veejay_create_tag(v, VJ_TAG_TYPE_DV1394, "/dev/dv1394", v->nstreams,0, 0) == 0) + int args[2]; + char *str = NULL; + P_A(args,str,format,ap); + + if(args[0] == -1) args[0] = 63; + veejay_msg(VEEJAY_MSG_DEBUG, "Try channel %d", args[0]); + if( veejay_create_tag(v, VJ_TAG_TYPE_DV1394, "/dev/dv1394", v->nstreams,0, args[0]) != 0) { - veejay_msg(VEEJAY_MSG_INFO, "Created new DV1394 stream %d", vj_tag_size()-1); + veejay_msg(VEEJAY_MSG_INFO, "Unable to create new DV1394 stream"); } } #ifdef HAVE_V4L @@ -5307,9 +5313,9 @@ void vj_event_tag_new_v4l(void *ptr, const char format[], va_list ap) sprintf(filename, "video%d", args[0]); - if( veejay_create_tag(v, VJ_TAG_TYPE_V4L, filename, v->nstreams,0,args[1]) == 0) + if( veejay_create_tag(v, VJ_TAG_TYPE_V4L, filename, v->nstreams,0,args[1]) != 0) { - veejay_msg(VEEJAY_MSG_INFO, "Created new Video4Linux stream %d", vj_tag_size()-1); + veejay_msg(VEEJAY_MSG_INFO, "Unable to create new Video4Linux stream "); } } #endif @@ -5321,9 +5327,9 @@ void vj_event_tag_new_net(void *ptr, const char format[], va_list ap) int args[2]; P_A(args,str,format,ap); - if( veejay_create_tag(v, VJ_TAG_TYPE_NET, str, v->nstreams, 0,args[0]) == 0 ) + if( veejay_create_tag(v, VJ_TAG_TYPE_NET, str, v->nstreams, 0,args[0]) != 0 ) { - veejay_msg(VEEJAY_MSG_INFO, "Created new input network stream %d", vj_tag_size()-1); + veejay_msg(VEEJAY_MSG_INFO, "Unable to create new Network stream"); } } @@ -5335,9 +5341,9 @@ void vj_event_tag_new_mcast(void *ptr, const char format[], va_list ap) int args[2]; P_A(args,str,format,ap); - if( veejay_create_tag(v, VJ_TAG_TYPE_MCAST, str, v->nstreams, 0,args[0]) == 0 ) + if( veejay_create_tag(v, VJ_TAG_TYPE_MCAST, str, v->nstreams, 0,args[0]) != 0 ) { - veejay_msg(VEEJAY_MSG_INFO, "Created new multicast stream %d", vj_tag_size()-1); + veejay_msg(VEEJAY_MSG_INFO, "Unable to create new multicast stream"); } } @@ -5347,9 +5353,9 @@ void vj_event_tag_new_y4m(void *ptr, const char format[], va_list ap) char str[255]; int *args = NULL; P_A(args,str,format,ap); - if( veejay_create_tag(v, VJ_TAG_TYPE_YUV4MPEG, str, v->nstreams,0,0) == 0) + if( veejay_create_tag(v, VJ_TAG_TYPE_YUV4MPEG, str, v->nstreams,0,0) != 0) { - veejay_msg(VEEJAY_MSG_INFO, "Created new YUV4MPEG stream %d", vj_tag_size()-1); + veejay_msg(VEEJAY_MSG_INFO, "Unable to create new Yuv4mpeg stream"); } } #ifdef HAVE_V4L