]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dv1394.c
attempt to demux clip wrapped content
[ffmpeg] / libavformat / dv1394.c
index 94c62f65b6618a1e2ce1ab4af43c665f920152bd..b3ab06a38537a6dd700941f6c6490835ec840ee6 100644 (file)
@@ -14,7 +14,7 @@
  *
  * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <unistd.h>
@@ -43,14 +43,12 @@ struct dv1394_data {
     int avail;  /* Number of frames available for reading */
     int done;   /* Number of completed frames */
 
-    int64_t pts;  /* Current timestamp */
-
     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.
  */
@@ -90,9 +88,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;
@@ -121,8 +119,6 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
         goto failed;
     }
 
-    av_set_pts_info(context, 48, 1, 1000000);
-
     if (dv1394_start(dv) < 0)
         goto failed;
 
@@ -130,7 +126,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)
@@ -140,7 +136,7 @@ static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt)
 
     size = dv_get_packet(dv->dv_demux, pkt);
     if (size > 0)
-        goto out;
+        return size;
 
     if (!dv->avail) {
         struct dv1394_status s;
@@ -152,9 +148,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);
             }
@@ -169,15 +165,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"
@@ -200,19 +196,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--;
-    dv->pts = av_gettime() & ((1LL << 48) - 1);
-    
-out:
-    pkt->pts = dv->pts;
+
     return size;
 }
 
@@ -234,7 +227,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),
@@ -243,9 +236,3 @@ static AVInputFormat dv1394_format = {
     .read_close     = dv1394_close,
     .flags          = AVFMT_NOFILE
 };
-
-int dv1394_init(void)
-{
-    av_register_input_format(&dv1394_format);
-    return 0;
-}