cpp/tests/test-network-data.cc
// test for data relocation after retrieving parity data which leads to BAD_ACCESS
// when accessing packet blobs
test for data relocation after retrieving parity data which leads to BAD_ACCESS
when accessing packet blobs
test for data relocation after retrieving parity data which leads to BAD_ACCESS when accessing packet blobs
TEST(TestVideoFramePacket, TestGetParity)
{
    std::srand(std::time(0));
    for (int i = 0; i < 100; ++i)
    {
        CommonHeader hdr;
        hdr.sampleRate_ = 24.7;
        hdr.publishTimestampMs_ = 488589553;
        hdr.publishUnixTimestamp_ = 1460488589;
        size_t frameLen = std::rand() % 30000 + 100;
        int32_t size = webrtc::CalcBufferSize(webrtc::kI420, 640, 480);
        uint8_t *buffer = (uint8_t *)malloc(frameLen);
        for (int i = 0; i < frameLen; ++i)
            buffer[i] = i % 255;
        webrtc::EncodedImage frame(buffer, frameLen, size);
        frame._encodedWidth = 640;
        frame._encodedHeight = 480;
        frame._timeStamp = 1460488589;
        frame.capture_time_ms_ = 1460488569;
        frame._frameType = webrtc::kVideoFrameKey;
        frame._completeFrame = true;
        VideoFramePacket vp(frame);
        std::map<std::string, PacketNumber> syncList = boost::assign::map_list_of("hi", 341)("mid", 433)("low", 432);
        vp.setSyncList(syncList);
        vp.setHeader(hdr);
        boost::shared_ptr<NetworkData> parity = vp.getParityData(VideoFrameSegment::payloadLength(8000), 0.2);
        EXPECT_EQ(hdr.sampleRate_, vp.getHeader().sampleRate_);
        EXPECT_EQ(hdr.publishTimestampMs_, vp.getHeader().publishTimestampMs_);
        EXPECT_EQ(hdr.publishUnixTimestamp_, vp.getHeader().publishUnixTimestamp_);
        EXPECT_EQ(frame._encodedWidth, vp.getFrame()._encodedWidth);
        EXPECT_EQ(frame._encodedHeight, vp.getFrame()._encodedHeight);
    }
}
TEST ( TestVideoFramePacket , TestGetParity ) { std :: srand ( std :: time ( 0 ) ) ; for ( int i = 0 ; i < 100 ; ++ i ) { CommonHeader hdr ; hdr . sampleRate_ = 24.7 ; hdr . publishTimestampMs_ = 488589553 ; hdr . publishUnixTimestamp_ = 1460488589 ; size_t frameLen = std :: rand ( ) % 30000 + 100 ; int32_t size = webrtc :: CalcBufferSize ( webrtc :: kI420 , 640 , 480 ) ; uint8_t * buffer = ( uint8_t * ) malloc ( frameLen ) ; for ( int i = 0 ; i < frameLen ; ++ i ) buffer [ i ] = i % 255 ; webrtc :: EncodedImage frame ( buffer , frameLen , size ) ; frame . _encodedWidth = 640 ; frame . _encodedHeight = 480 ; frame . _timeStamp = 1460488589 ; frame . capture_time_ms_ = 1460488569 ; frame . _frameType = webrtc :: kVideoFrameKey ; frame . _completeFrame = true ; VideoFramePacket vp ( frame ) ; std :: map < std :: string , PacketNumber > syncList = boost :: assign :: map_list_of ( " " , 341 ) ( " " , 433 ) ( " " , 432 ) ; vp . setSyncList ( syncList ) ; vp . setHeader ( hdr ) ; boost :: shared_ptr < NetworkData > parity = vp . getParityData ( VideoFrameSegment :: payloadLength ( 8000 ) , 0.2 ) ; EXPECT_EQ ( hdr . sampleRate_ , vp . getHeader ( ) . sampleRate_ ) ; EXPECT_EQ ( hdr . publishTimestampMs_ , vp . getHeader ( ) . publishTimestampMs_ ) ; EXPECT_EQ ( hdr . publishUnixTimestamp_ , vp . getHeader ( ) . publishUnixTimestamp_ ) ; EXPECT_EQ ( frame . _encodedWidth , vp . getFrame ( ) . _encodedWidth ) ; EXPECT_EQ ( frame . _encodedHeight , vp . getFrame ( ) . _encodedHeight ) ; } }
test for data relocation after retrieving parity data which leads to BAD_ACCESS
when accessing packet blobs
test for data relocation after retrieving parity data which leads to BAD_ACCESS when accessing packet blobs