mirror of https://github.com/ossrs/srs.git
add utest for kernel codec
parent
492665e166
commit
f5f54e6008
@ -0,0 +1,109 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <srs_utest_kernel.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <srs_kernel_error.hpp>
|
||||
|
||||
VOID TEST(KernelCodecTest, IsKeyFrame)
|
||||
{
|
||||
int8_t data;
|
||||
|
||||
data = 0x10;
|
||||
EXPECT_TRUE(SrsFlvCodec::video_is_keyframe(&data, 1));
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_keyframe(&data, 0));
|
||||
|
||||
data = 0x20;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_keyframe(&data, 1));
|
||||
}
|
||||
|
||||
VOID TEST(KernelCodecTest, IsH264)
|
||||
{
|
||||
int8_t data;
|
||||
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_h264(&data, 0));
|
||||
|
||||
data = 0x17;
|
||||
EXPECT_TRUE(SrsFlvCodec::video_is_h264(&data, 1));
|
||||
|
||||
data = 0x07;
|
||||
EXPECT_TRUE(SrsFlvCodec::video_is_h264(&data, 1));
|
||||
|
||||
data = 0x08;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_h264(&data, 1));
|
||||
}
|
||||
|
||||
VOID TEST(KernelCodecTest, IsSequenceHeader)
|
||||
{
|
||||
int16_t data;
|
||||
char* pp = (char*)&data;
|
||||
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 0));
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 1));
|
||||
|
||||
pp[0] = 0x17;
|
||||
pp[1] = 0x00;
|
||||
EXPECT_TRUE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 2));
|
||||
pp[0] = 0x18;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 2));
|
||||
pp[0] = 0x27;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 2));
|
||||
pp[0] = 0x17;
|
||||
pp[1] = 0x01;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 2));
|
||||
}
|
||||
|
||||
VOID TEST(KernelCodecTest, IsAAC)
|
||||
{
|
||||
int8_t data;
|
||||
|
||||
EXPECT_FALSE(SrsFlvCodec::audio_is_aac(&data, 0));
|
||||
|
||||
data = 0xa0;
|
||||
EXPECT_TRUE(SrsFlvCodec::audio_is_aac(&data, 1));
|
||||
|
||||
data = 0xa7;
|
||||
EXPECT_TRUE(SrsFlvCodec::audio_is_aac(&data, 1));
|
||||
|
||||
data = 0x00;
|
||||
EXPECT_FALSE(SrsFlvCodec::audio_is_aac(&data, 1));
|
||||
}
|
||||
|
||||
VOID TEST(KernelCodecTest, IsAudioSequenceHeader)
|
||||
{
|
||||
int16_t data;
|
||||
char* pp = (char*)&data;
|
||||
|
||||
EXPECT_FALSE(SrsFlvCodec::audio_is_sequence_header((int8_t*)pp, 0));
|
||||
EXPECT_FALSE(SrsFlvCodec::audio_is_sequence_header((int8_t*)pp, 1));
|
||||
|
||||
pp[0] = 0xa0;
|
||||
pp[1] = 0x00;
|
||||
EXPECT_TRUE(SrsFlvCodec::audio_is_sequence_header((int8_t*)pp, 2));
|
||||
pp[0] = 0x00;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 2));
|
||||
pp[0] = 0xa0;
|
||||
pp[1] = 0x01;
|
||||
EXPECT_FALSE(SrsFlvCodec::video_is_sequence_header((int8_t*)pp, 2));
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_UTEST_KERNEL_HPP
|
||||
#define SRS_UTEST_KERNEL_HPP
|
||||
|
||||
/*
|
||||
#include <srs_utest_kernel.hpp>
|
||||
*/
|
||||
#include <srs_utest.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <srs_kernel_codec.hpp>
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue