Commit 89c7a92e authored by François Grisez's avatar François Grisez

Add a test playing "one NALu per frame scenario with the MKV recorder

parent 74f20fac
......@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msticker.h"
#include "mediastreamer2/msfactory.h"
#include "mediastreamer2/msvideo.h"
static MSFactory *_factory = NULL;
......@@ -47,10 +48,9 @@ static void decoder_events_cb(void *userdata, MSFilter *decoder, unsigned int id
}
}
static void play_scenario(MSFilterDesc *decoder_desc, const char *pcap_scenario_file) {
static void play_scenario(MSFilterDesc *decoder_desc, const char *pcap_scenario_file, MSFilter *output) {
MSFilter *player = ms_factory_create_filter(_factory, MS_FILE_PLAYER_ID);
MSFilter *decoder = ms_factory_create_filter_from_desc(_factory, decoder_desc);
MSFilter *output = ms_factory_create_filter(_factory, MS_VOID_SINK_ID);
MSTicker *ticker = ms_ticker_new();
bool_t eof = FALSE;
bool_t first_frame_decoded = FALSE;
......@@ -86,20 +86,56 @@ static void play_scenario(MSFilterDesc *decoder_desc, const char *pcap_scenario_
end:
if(player) ms_filter_destroy(player);
if(decoder) ms_filter_destroy(decoder);
if(output) ms_filter_destroy(output);
if(ticker) ms_ticker_destroy(ticker);
}
static void play_scenario_for_all_decoders(const char *mime, const char *pcap_scenario_file) {
MSList *it;
MSFilter *output = ms_factory_create_filter(_factory, MS_VOID_SINK_ID);
bctbx_list_t *it;
for(it=_factory->desc_list; it!=NULL; it=it->next) {
MSFilterDesc *desc = (MSFilterDesc *)it->data;
if(desc->category == MS_FILTER_DECODER && strcasecmp(desc->enc_fmt, mime) == 0) {
ms_message("\n");
ms_message("Playing scenario with '%s' decoder", desc->name);
play_scenario(desc, pcap_scenario_file);
play_scenario(desc, pcap_scenario_file, output);
}
}
ms_filter_destroy(output);
}
static void play_scenario_with_mkv_recorder(const char *pcap_scenario_file, const MSFmtDescriptor *fmt) {
MSFilter *player = ms_factory_create_filter(_factory, MS_FILE_PLAYER_ID);
MSFilter *recorder = ms_factory_create_filter(_factory, MS_MKV_RECORDER_ID);
MSTicker *ticker = ms_ticker_new();
MSPinFormat pinfmt = {0, fmt};
char *output_file = bctbx_strdup_printf("%s/output.mkv", bc_tester_get_writable_dir_prefix());
bool_t eof = FALSE;
unlink(output_file);
ms_filter_link(player, 0, recorder, 0);
ms_filter_add_notify_callback(player, player_events_cb, &eof, TRUE);
ms_filter_call_method(player, MS_PLAYER_OPEN, (char *)pcap_scenario_file);
ms_filter_call_method(recorder, MS_FILTER_SET_INPUT_FMT, &pinfmt);
ms_filter_call_method(recorder, MS_RECORDER_OPEN, output_file);
ms_ticker_attach(ticker, player);
ms_filter_call_method_noarg(recorder, MS_RECORDER_START);
ms_filter_call_method_noarg(player, MS_PLAYER_START);
while (!eof) {
ms_usleep(100000);
}
ms_ticker_detach(ticker, player);
ms_filter_unlink(player, 0, recorder, 0);
ms_filter_destroy(player);
ms_filter_destroy(recorder);
ms_ticker_destroy(ticker);
unlink(output_file);
bctbx_free(output_file);
}
#define scenario_test(scenario_name) \
......@@ -114,9 +150,17 @@ static void scenario_name(void) { \
scenario_test(h264_missing_pps_in_second_i_frame)
scenario_test(h264_one_nalu_per_frame)
void h264_one_nalu_per_frame_with_mkv_recorder(void) {
const MSFmtDescriptor *fmt = ms_factory_get_video_format(_factory, "h264", MS_VIDEO_SIZE_VGA, 15, NULL);
char *scenario_pcap_file = bctbx_strdup_printf("%s/scenarios/h264_one_nalu_per_frame.pcap",bc_tester_get_resource_dir_prefix());
play_scenario_with_mkv_recorder(scenario_pcap_file, fmt);
bctbx_free(scenario_pcap_file);
}
static test_t tests[] = {
{ "H264: missing PPS in second i-frame scenario" , h264_missing_pps_in_second_i_frame },
{ "H264: one NALu per frame scenario" , h264_one_nalu_per_frame }
{ "H264: missing PPS in second i-frame scenario" , h264_missing_pps_in_second_i_frame },
{ "H264: one NALu per frame scenario" , h264_one_nalu_per_frame },
{ "H264: one NALu per frame scenario (MKV recorder)" , h264_one_nalu_per_frame_with_mkv_recorder }
};
test_suite_t codec_impl_test_suite = {
......
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