From 50b586b9de53b4e0c7bb0197172bd340b9455d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20G=C3=BCnther?= Date: Wed, 9 Jul 2014 18:44:50 +0200 Subject: [PATCH] Media Kit: Add workaround for #11018 to MPEG2 video stream decoder test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The workaround triggers the loading of all media plugins prior to using methods of class BMediaFormats. Using the function get_next_encoder() is used because of two facts 1. It is publicly available and thus can be used by 3rd party apps, too. 2. It is already available by including BMediaFormats.h, so there is no need to include another header for this workaround. Signed-off-by: Colin Günther (cherry picked from commit 80354716fe8b25c81ec45bd96ae36e171228b8a0) --- .../mpeg2_decoder_test/mpeg2_decoder_test.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/tests/kits/media/mpeg2_decoder_test/mpeg2_decoder_test.cpp b/src/tests/kits/media/mpeg2_decoder_test/mpeg2_decoder_test.cpp index c943abb8b8..8d65ad9c7d 100644 --- a/src/tests/kits/media/mpeg2_decoder_test/mpeg2_decoder_test.cpp +++ b/src/tests/kits/media/mpeg2_decoder_test/mpeg2_decoder_test.cpp @@ -120,6 +120,27 @@ main(int argc, char* argv[]) BFile* mpeg2EncodedFile = new BFile(kTestVideoFilename, O_RDONLY); BMediaDecoder* mpeg2Decoder = new FileDecoder(mpeg2EncodedFile); + // TODO: The following code block is a workaround for the bug #11018 + // (https://dev.haiku-os.org/ticket/11018). Please remove this code block, + // once the bug is being resolved. + // The workaround triggers the loading of all media plugins prior to using + // methods of class BMediaFormats. Using the function get_next_encoder() + // is used because of two facts + // 1. It is publicly available and thus can be used by 3rd party apps, + // too. + // 2. It is already available by including BMediaFormats.h, so there is + // no need to include another header for this workaround. + // Also, please leave the workaround code at this -prominent- place + // instead of moving it to the more appropriate place in + // CreateMpeg2MediaFormat(). This way it acts as a reminder to fix + // the bug :) + int32 workaroundCookie = 0; + media_codec_info workaroundMediaCodecInfo; + status_t workaroundStatus = get_next_encoder(&workaroundCookie, + &workaroundMediaCodecInfo); + if (workaroundStatus < B_OK) + exit(99); + media_format* mpeg2MediaFormat = CreateMpeg2MediaFormat(); mpeg2Decoder->SetTo(mpeg2MediaFormat); status_t settingMpeg2DecoderStatus = mpeg2Decoder->InitCheck(); @@ -192,7 +213,7 @@ CreateMpeg2MediaFormat() return kFailedToCreateMpeg2MediaFormat; } - // The following code block can be removed, once the ffmpeg addon can + // TODO: The following code block can be removed, once the ffmpeg addon can // determine the codec output parameters from the encoded data. mpeg2MediaFormat->u.encoded_video.output.first_active = 0; mpeg2MediaFormat->u.encoded_video.output.last_active = 575;