Commit da5b10f5 authored by Simon Morlat's avatar Simon Morlat

Improve pcap_playback, improve logs of rfc3984 unpacker.

parent 31e7d4f5
......@@ -242,6 +242,7 @@ AC_DEFUN([MS_CHECK_VIDEO],[
fi
PKG_CHECK_MODULES(GLEW,[glew >= 1.5])
AC_CHECK_HEADERS(X11/Xlib.h)
AC_DEFINE(HAVE_GLX, 1, [defined if GLX is available])
fi
AC_ARG_ENABLE(theora,
......
......@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msfileplayer.h"
#include "waveheader.h"
#include "mediastreamer2/msticker.h"
#include <ortp/rtp.h>
#include <pcap/pcap.h>
......@@ -252,11 +253,12 @@ static void player_process(MSFilter *f){
om->b_wptr += bytes_pcap;
} else {
if (pcap_seq >= d->pcap_seq) {
rtp_header_t *rtph = (rtp_header_t*)rtp_header;
om = allocb(bytes_pcap, 0);
memcpy(om->b_wptr, payload, bytes_pcap);
om->b_wptr += bytes_pcap;
mblk_set_cseq(om, pcap_seq);
mblk_set_timestamp_info(om, f->ticker->time);
mblk_set_cseq(om, ntohs(rtph->seq_number));
mblk_set_timestamp_info(om, ntohl(rtph->timestamp));
mblk_set_marker_info(om,markbit);
}
}
......
......@@ -285,7 +285,8 @@ static unsigned int output_frame(Rfc3984Context * ctx, MSQueue *out, unsigned in
if ((res & Rfc3984FrameCorrupted) == 0){
if ((res & Rfc3984HasSPS) && (res & Rfc3984HasPPS) && !(res & Rfc3984HasIDR)){
/*some decoders may not be happy with this*/
ms_warning("rfc3984_unpack: a frame with SPS+PPS but no IDR was output.");
ms_warning("rfc3984_unpack: a frame with SPS+PPS but no IDR was output, starting at seq number %u",
mblk_get_cseq(ms_queue_peek_first(&ctx->q)));
}
}
......@@ -347,13 +348,16 @@ unsigned int rfc3984_unpack2(Rfc3984Context *ctx, mblk_t *im, MSQueue *out){
uint16_t cseq=mblk_get_cseq(im);
unsigned int ret = 0;
//ms_message("Seeing timestamp %u, sequence %u", ts, (int)cseq);
if (ctx->last_ts!=ts){
/*a new frame is arriving, in case the marker bit was not set in previous frame, output it now,
unless it is a FU-A packet (workaround for buggy implementations)*/
ctx->last_ts=ts;
if (ctx->m==NULL && !ms_queue_empty(&ctx->q)){
ret = output_frame(ctx, out, Rfc3984FrameAvailable | Rfc3984FrameCorrupted);
ms_warning("Incomplete H264 frame (missing marker bit)");
ms_warning("Incomplete H264 frame (missing marker bit after seq number %u)",
mblk_get_cseq(ms_queue_peek_last(out)));
}
}
......
......@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/msvolume.h"
#include "mediastreamer2/msfilerec.h"
#include "mediastreamer2/mspcapfileplayer.h"
#ifdef VIDEO_ENABLED
#include "mediastreamer2/msv4l.h"
#endif
......@@ -87,6 +88,7 @@ const char *usage = "pcap_playback --infile <pcapfile>\n"
"[ --playback-card <name> ]\n"
"[ --outfile <name> ] limited to wav file for now\n"
"[ --verbose (most verbose messages) ]\n"
"This tool directly renders a pcap file to soundcard or screen (for video), using mediastreamer2 filters.\n"
;
......@@ -175,7 +177,7 @@ static bool_t parse_args(int argc, char **argv, MediastreamDatas *out)
static void reader_notify_cb(void *user_data, MSFilter *f, unsigned int event, void *eventdata)
{
if (event == MS_FILE_PLAYER_EOF) {
if (event == MS_PLAYER_EOF) {
cond = 0;
}
}
......@@ -236,6 +238,8 @@ static void configure_resampler(MSFilter *resampler,MSFilter *from, MSFilter *to
static void setup_media_streams(MediastreamDatas *args) {
MSConnectionHelper h;
MSTickerParams params = {0};
MSPCAPFilePlayerLayer layer = MSPCAPFilePlayerLayerPayload;
MSPCAPFilePlayerTimeRef timeref = MSPCAPFilePlayerTimeRefCapture;
/*create the rtp session */
ortp_init();
......@@ -289,7 +293,7 @@ static void setup_media_streams(MediastreamDatas *args) {
#else
display_name = "MSVideoOut";
#endif
args->read = ms_factory_create_filter(factory, MS_FILE_PLAYER_ID);
args->read = ms_factory_create_filter(factory, MS_PCAP_FILE_PLAYER_ID);
args->write = ms_factory_create_filter_from_name(factory, display_name);
args->decoder = ms_factory_create_decoder(factory, args->pt->mime_type);
if (args->decoder==NULL){
......@@ -299,10 +303,12 @@ static void setup_media_streams(MediastreamDatas *args) {
if (ms_filter_call_method(args->decoder,MS_VIDEO_DECODER_ENABLE_AVPF,&args->avpf)==0){
ms_filter_add_notify_callback(args->decoder, video_decoder_callback, NULL, TRUE);
}
ms_filter_call_method_noarg(args->read, MS_FILE_PLAYER_CLOSE);
ms_filter_call_method(args->read, MS_FILE_PLAYER_OPEN, args->infile);
ms_filter_call_method_noarg(args->read, MS_PLAYER_CLOSE);
ms_filter_call_method(args->read, MS_PLAYER_OPEN, args->infile);
ms_filter_call_method(args->read, MS_FILTER_SET_SAMPLE_RATE, &args->pt->clock_rate);
ms_filter_call_method_noarg(args->read, MS_FILE_PLAYER_START);
ms_filter_call_method_noarg(args->read, MS_PLAYER_START);
ms_filter_call_method(args->read, MS_PCAP_FILE_PLAYER_SET_LAYER, &layer);
ms_filter_call_method(args->read, MS_PCAP_FILE_PLAYER_SET_TIMEREF, &timeref);
ms_filter_add_notify_callback(args->read, reader_notify_cb, NULL,FALSE);
/*force the decoder to output YUV420P */
......@@ -344,13 +350,16 @@ static void setup_media_streams(MediastreamDatas *args) {
args->write = ms_snd_card_create_writer(play);
}
args->read = ms_factory_create_filter(factory, MS_FILE_PLAYER_ID);
args->read = ms_factory_create_filter(factory, MS_PCAP_FILE_PLAYER_ID);
args->decoder = ms_factory_create_decoder(factory, args->pt->mime_type);
args->resampler = ms_factory_create_filter(factory, MS_RESAMPLE_ID);
ms_filter_call_method_noarg(args->read, MS_FILE_PLAYER_CLOSE);
ms_filter_call_method(args->read, MS_FILE_PLAYER_OPEN, args->infile);
ms_filter_call_method_noarg(args->read, MS_FILE_PLAYER_START);
ms_filter_call_method_noarg(args->read, MS_PLAYER_CLOSE);
ms_filter_call_method(args->read, MS_PLAYER_OPEN, args->infile);
ms_filter_call_method_noarg(args->read, MS_PLAYER_START);
ms_filter_call_method(args->read, MS_FILTER_SET_SAMPLE_RATE, &args->pt->clock_rate);
ms_filter_call_method(args->read, MS_PCAP_FILE_PLAYER_SET_LAYER, &layer);
ms_filter_call_method(args->read, MS_PCAP_FILE_PLAYER_SET_TIMEREF, &timeref);
ms_filter_call_method(args->decoder, MS_FILTER_SET_SAMPLE_RATE, &args->pt->clock_rate);
ms_filter_call_method(args->decoder, MS_FILTER_SET_NCHANNELS, &args->pt->channels);
ms_filter_call_method(args->write, MS_FILTER_SET_SAMPLE_RATE, &args->pt->clock_rate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment