def test_deserialize_video_data(fd): tag = Tag.deserialize(fd) assert tag.type == TAG_TYPE_VIDEO assert tag.timestamp == 123 assert isinstance(tag.data, VideoData) assert tag.data.type == VIDEO_FRAME_TYPE_KEY_FRAME assert tag.data.codec == VIDEO_CODEC_ID_AVC assert isinstance(tag.data.data, AVCVideoData) assert tag.data.data.type == AVC_PACKET_TYPE_NALU assert tag.data.data.data == b"video data" assert fd.tell() == VIDEO_DATA_SIZE
def test_deserialize_from_video_data(): buf = VIDEO_DATA * 2 offset = 0 tag, offset = Tag.deserialize_from(buf, offset) assert tag.type == TAG_TYPE_VIDEO assert tag.timestamp == 123 assert isinstance(tag.data, VideoData) assert tag.data.type == VIDEO_FRAME_TYPE_KEY_FRAME assert tag.data.codec == VIDEO_CODEC_ID_AVC assert isinstance(tag.data.data, AVCVideoData) assert tag.data.data.type == AVC_PACKET_TYPE_NALU assert tag.data.data.data == b"video data" assert offset == VIDEO_DATA_SIZE
def create_video_tag(): avc = AVCVideoData(AVC_PACKET_TYPE_NALU, 0, b"video data") videodata = VideoData(VIDEO_FRAME_TYPE_KEY_FRAME, VIDEO_CODEC_ID_AVC, avc) tag = Tag(TAG_TYPE_VIDEO, 123, videodata) return tag