]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dv1394.c
better warning
[ffmpeg] / libavformat / dv1394.c
index cf64a250cb57678c830d10db917fe49c3cfc8b58..f00d474357640a2eddafdf1bf3fffd923408a29d 100644 (file)
@@ -2,19 +2,21 @@
  * Linux DV1394 interface
  * Copyright (c) 2003 Max Krasnyansky <maxk@qualcomm.com>
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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 of the License, or (at your option) any later version.
+ * 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,
+ * FFmpeg 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <unistd.h>
@@ -46,9 +48,9 @@ struct dv1394_data {
     DVDemuxContext* dv_demux; /* Generic DV muxing/demuxing context */
 };
 
-/* 
+/*
  * The trick here is to kludge around well known problem with kernel Ooopsing
- * when you try to capture PAL on a device node configure for NTSC. That's 
+ * when you try to capture PAL on a device node configure for NTSC. That's
  * why we have to configure the device node for PAL, and then read only NTSC
  * amount of data.
  */
@@ -88,9 +90,9 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
         goto failed;
 
     if (ap->standard && !strcasecmp(ap->standard, "pal"))
-       dv->format = DV1394_PAL;
+        dv->format = DV1394_PAL;
     else
-       dv->format = DV1394_NTSC;
+        dv->format = DV1394_NTSC;
 
     if (ap->channel)
         dv->channel = ap->channel;
@@ -126,7 +128,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
 
 failed:
     close(dv->fd);
-    return -EIO;
+    return AVERROR_IO;
 }
 
 static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt)
@@ -148,9 +150,9 @@ static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt)
                 /* This usually means that ring buffer overflowed.
                  * We have to reset :(.
                  */
-  
+
                 av_log(context, AV_LOG_ERROR, "DV1394: Ring buffer overflow. Reseting ..\n");
+
                 dv1394_reset(dv);
                 dv1394_start(dv);
             }
@@ -165,15 +167,15 @@ restart_poll:
             if (errno == EAGAIN || errno == EINTR)
                 goto restart_poll;
             perror("Poll failed");
-            return -EIO;
+            return AVERROR_IO;
         }
 
         if (ioctl(dv->fd, DV1394_GET_STATUS, &s) < 0) {
             perror("Failed to get status");
-            return -EIO;
+            return AVERROR_IO;
         }
 #ifdef DV1394_DEBUG
-        fprintf(stderr, "DV1394: status\n"
+        av_log(context, AV_LOG_DEBUG, "DV1394: status\n"
                 "\tactive_frame\t%d\n"
                 "\tfirst_clear_frame\t%d\n"
                 "\tn_clear_frames\t%d\n"
@@ -196,16 +198,16 @@ restart_poll:
     }
 
 #ifdef DV1394_DEBUG
-    fprintf(stderr, "index %d, avail %d, done %d\n", dv->index, dv->avail,
+    av_log(context, AV_LOG_DEBUG, "index %d, avail %d, done %d\n", dv->index, dv->avail,
             dv->done);
 #endif
 
-    size = dv_produce_packet(dv->dv_demux, pkt, 
-                             dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE), 
-                            DV1394_PAL_FRAME_SIZE);
+    size = dv_produce_packet(dv->dv_demux, pkt,
+                             dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE),
+                             DV1394_PAL_FRAME_SIZE);
     dv->index = (dv->index + 1) % DV1394_RING_FRAMES;
     dv->done++; dv->avail--;
-    
+
     return size;
 }
 
@@ -227,7 +229,7 @@ static int dv1394_close(AVFormatContext * context)
     return 0;
 }
 
-static AVInputFormat dv1394_format = {
+AVInputFormat dv1394_demuxer = {
     .name           = "dv1394",
     .long_name      = "dv1394 A/V grab",
     .priv_data_size = sizeof(struct dv1394_data),
@@ -236,9 +238,3 @@ static AVInputFormat dv1394_format = {
     .read_close     = dv1394_close,
     .flags          = AVFMT_NOFILE
 };
-
-int dv1394_init(void)
-{
-    av_register_input_format(&dv1394_format);
-    return 0;
-}