*
* 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>
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.
*/
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;
goto failed;
}
- av_set_pts_info(context, 48, 1, 1000000);
-
if (dv1394_start(dv) < 0)
goto failed;
failed:
close(dv->fd);
- return -EIO;
+ return AVERROR_IO;
}
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;
/* This usually means that ring buffer overflowed.
* We have to reset :(.
*/
-
- fprintf(stderr, "DV1394: Ring buffer overflow. Reseting ..\n");
-
+
+ av_log(context, AV_LOG_ERROR, "DV1394: Ring buffer overflow. Reseting ..\n");
+
dv1394_reset(dv);
dv1394_start(dv);
}
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"
dv->done = 0;
if (s.dropped_frames) {
- fprintf(stderr, "DV1394: Frame drop detected (%d). Reseting ..\n",
+ av_log(context, AV_LOG_ERROR, "DV1394: Frame drop detected (%d). Reseting ..\n",
s.dropped_frames);
dv1394_reset(dv);
}
#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;
}
return 0;
}
-static AVInputFormat dv1394_format = {
+AVInputFormat dv1394_demuxer = {
.name = "dv1394",
.long_name = "dv1394 A/V grab",
.priv_data_size = sizeof(struct dv1394_data),
.read_close = dv1394_close,
.flags = AVFMT_NOFILE
};
-
-int dv1394_init(void)
-{
- av_register_input_format(&dv1394_format);
- return 0;
-}