Lines Matching refs:dv

33 #include "libavformat/dv.h"
91 int (*parse_queue)(struct iec61883_data *dv, AVPacket *pkt);
103 struct iec61883_data *dv = callback_data;
108 pthread_mutex_lock(&dv->mutex);
111 if (dv->packets >= dv->max_packets) {
134 if (dv->queue_first) {
135 dv->queue_last->next = packet;
136 dv->queue_last = packet;
138 dv->queue_first = packet;
139 dv->queue_last = packet;
141 dv->packets++;
147 pthread_cond_broadcast(&dv->cond);
148 pthread_mutex_unlock(&dv->mutex);
155 struct iec61883_data *dv = (struct iec61883_data *)opaque;
159 while (dv->thread_loop)
162 while ((result = poll(&dv->raw1394_poll, 1, 200)) < 0) {
165 dv->receive_error = AVERROR(EIO);
169 if (result > 0 && ((dv->raw1394_poll.revents & POLLIN)
170 || (dv->raw1394_poll.revents & POLLPRI))) {
171 dv->receiving = 1;
172 raw1394_loop_iterate(dv->raw1394);
173 } else if (dv->receiving) {
176 pthread_mutex_lock(&dv->mutex);
177 dv->eof = 1;
178 pthread_cond_broadcast(&dv->cond);
179 pthread_mutex_unlock(&dv->mutex);
181 dv->eof = 1;
190 static int iec61883_parse_queue_dv(struct iec61883_data *dv, AVPacket *pkt)
195 size = avpriv_dv_get_packet(dv->dv_demux, pkt);
199 packet = dv->queue_first;
203 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
205 dv->queue_first = packet->next;
209 dv->packets--;
223 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)
229 while (dv->queue_first) {
230 packet = dv->queue_first;
231 size = avpriv_mpegts_parse_packet(dv->mpeg_demux, pkt, packet->buf,
233 dv->queue_first = packet->next;
236 dv->packets--;
247 struct iec61883_data *dv = context->priv_data;
258 dv->input_port = -1;
259 dv->output_port = -1;
260 dv->channel = -1;
262 dv->raw1394 = raw1394_new_handle();
264 if (!dv->raw1394) {
269 if ((nb_ports = raw1394_get_port_info(dv->raw1394, pinf, 16)) < 0) {
285 if (dv->device_guid) {
286 if (sscanf(dv->device_guid, "%"SCNu64, &guid) != 1) {
288 dv->device_guid);
294 raw1394_destroy_handle(dv->raw1394);
296 if (!(dv->raw1394 = raw1394_new_handle_on_port(j))) {
301 for (i=0; i<raw1394_get_nodecount(dv->raw1394); ++i) {
306 if (guid == rom1394_get_guid(dv->raw1394, i)) {
307 dv->node = i;
315 if (rom1394_get_directory(dv->raw1394, i, &rom_dir) < 0)
318 avc1394_check_subunit_type(dv->raw1394, i, AVC1394_SUBUNIT_TYPE_VCR)) ||
321 dv->node = i;
337 iec61883_cmp_normalize_output(dv->raw1394, 0xffc0 | dv->node);
341 if (dv->type == IEC61883_AUTO) {
342 response = avc1394_transaction(dv->raw1394, dv->node,
349 dv->type = (response == 0x10 || response == 0x90 || response == 0x1A || response == 0x9A) ?
355 dv->channel = iec61883_cmp_connect(dv->raw1394, dv->node, &dv->output_port,
356 raw1394_get_local_id(dv->raw1394),
357 &dv->input_port, &dv->bandwidth);
359 if (dv->channel < 0)
360 dv->channel = 63;
362 if (!dv->max_packets)
363 dv->max_packets = 100;
365 if (CONFIG_MPEGTS_DEMUXER && dv->type == IEC61883_HDV) {
371 dv->mpeg_demux = avpriv_mpegts_parse_open(context);
372 if (!dv->mpeg_demux)
375 dv->parse_queue = iec61883_parse_queue_hdv;
377 dv->iec61883_mpeg2 = iec61883_mpeg2_recv_init(dv->raw1394,
379 dv);
381 dv->max_packets *= 766;
386 dv->dv_demux = avpriv_dv_init_demux(context);
387 if (!dv->dv_demux)
390 dv->parse_queue = iec61883_parse_queue_dv;
392 dv->iec61883_dv = iec61883_dv_fb_init(dv->raw1394, iec61883_callback, dv);
395 dv->raw1394_poll.fd = raw1394_get_fd(dv->raw1394);
396 dv->raw1394_poll.events = POLLIN | POLLERR | POLLHUP | POLLPRI;
400 if (dv->type == IEC61883_HDV)
401 iec61883_mpeg2_recv_start(dv->iec61883_mpeg2, dv->channel);
403 iec61883_dv_fb_start(dv->iec61883_dv, dv->channel);
406 dv->thread_loop = 1;
407 if (pthread_mutex_init(&dv->mutex, NULL))
409 if (pthread_cond_init(&dv->cond, NULL))
411 if (pthread_create(&dv->receive_task_thread, NULL, iec61883_receive_task, dv))
418 raw1394_destroy_handle(dv->raw1394);
424 struct iec61883_data *dv = context->priv_data;
432 pthread_mutex_lock(&dv->mutex);
433 while ((size = dv->parse_queue(dv, pkt)) == -1)
434 if (!dv->eof)
435 pthread_cond_wait(&dv->cond, &dv->mutex);
438 pthread_mutex_unlock(&dv->mutex);
441 while ((size = dv->parse_queue(dv, pkt)) == -1) {
442 iec61883_receive_task((void *)dv);
443 if (dv->receive_error)
444 return dv->receive_error;
453 struct iec61883_data *dv = context->priv_data;
456 dv->thread_loop = 0;
457 pthread_join(dv->receive_task_thread, NULL);
458 pthread_cond_destroy(&dv->cond);
459 pthread_mutex_destroy(&dv->mutex);
462 if (CONFIG_MPEGTS_DEMUXER && dv->type == IEC61883_HDV) {
463 iec61883_mpeg2_recv_stop(dv->iec61883_mpeg2);
464 iec61883_mpeg2_close(dv->iec61883_mpeg2);
465 avpriv_mpegts_parse_close(dv->mpeg_demux);
467 iec61883_dv_fb_stop(dv->iec61883_dv);
468 iec61883_dv_fb_close(dv->iec61883_dv);
469 av_freep(&dv->dv_demux);
471 while (dv->queue_first) {
472 DVPacket *packet = dv->queue_first;
473 dv->queue_first = packet->next;
478 iec61883_cmp_disconnect(dv->raw1394, dv->node, dv->output_port,
479 raw1394_get_local_id(dv->raw1394),
480 dv->input_port, dv->channel, dv->bandwidth);
482 raw1394_destroy_handle(dv->raw1394);
490 { "dv", "force device being treated as DV device", 0, AV_OPT_TYPE_CONST, {.i64 = IEC61883_DV}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "dvtype" },