MCPcopy Create free account
hub / github.com/cisco/openh264 / TestEndOfStream

Method TestEndOfStream

test/decoder/DecUT_DecExt.cpp:339–397  ·  view source on GitHub ↗

DECODER_OPTION_END_OF_STREAM

Source from the content-addressed store, hash-verified

337
338//DECODER_OPTION_END_OF_STREAM
339void DecoderInterfaceTest::TestEndOfStream() {
340 int iTmp, iOut;
341 CM_RETURN eRet;
342 int32_t iRet = ERR_NONE;
343
344 iRet = ValidInit();
345 ASSERT_EQ (iRet, ERR_NONE);
346
347 //invalid input
348 eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, NULL);
349 EXPECT_EQ (eRet, cmInitParaError);
350
351 //valid random input
352 for (int i = 0; i < 10; ++i) {
353 iTmp = rand();
354 eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, &iTmp);
355 EXPECT_EQ (eRet, cmResultSuccess);
356 eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
357 EXPECT_EQ (eRet, cmResultSuccess);
358 EXPECT_EQ (iOut, iTmp != 0 ? 1 : 0);
359 }
360
361 //set false as input
362 iTmp = false;
363 eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, &iTmp);
364 EXPECT_EQ (eRet, cmResultSuccess);
365 eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
366 EXPECT_EQ (eRet, cmResultSuccess);
367
368 EXPECT_EQ (iOut, 0);
369
370 //set true as input
371 iTmp = true;
372 eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, &iTmp);
373 EXPECT_EQ (eRet, cmResultSuccess);
374 eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
375 EXPECT_EQ (eRet, cmResultSuccess);
376
377 EXPECT_EQ (iOut, 1);
378
379 //Mock data packet in
380 //Test NULL data input for decoder, should be true for EOS
381 eRet = (CM_RETURN) m_pDec->DecodeFrame2 (NULL, 0, m_pData, &m_sBufferInfo);
382 EXPECT_EQ (eRet, 0); //decode should return OK
383 eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
384 EXPECT_EQ (iOut, 1); //decoder should have EOS == true
385
386 //Test valid data input for decoder, should be false for EOS
387 MockPacketType (NAL_UNIT_UNSPEC_0, 50);
388 eRet = (CM_RETURN) m_pDec->DecodeFrame2 (m_szBuffer, m_iBufLength, m_pData, &m_sBufferInfo);
389 eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
390 EXPECT_EQ (iOut, 0); //decoder should have EOS == false
391 //Test NULL data input for decoder, should be true for EOS
392 eRet = (CM_RETURN) m_pDec->DecodeFrame2 (NULL, 0, m_pData, &m_sBufferInfo);
393 eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOut);
394 EXPECT_EQ (iOut, 1); //decoder should have EOS == true
395
396 Uninit();

Callers

nothing calls this directly

Calls 4

UninitFunction · 0.85
SetOptionMethod · 0.45
GetOptionMethod · 0.45
DecodeFrame2Method · 0.45

Tested by

no test coverage detected