Skip to content

Commit 709e52d

Browse files
alfredoyangkinetiknz
authored andcommitted
Set avc extra_data
1 parent 9378b80 commit 709e52d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

mp4parse_capi/examples/afl-capi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fn doit() {
5252
display_height: 0,
5353
image_width: 0,
5454
image_height: 0,
55+
extra_data: mp4parse_byte_data::default(),
5556
};
5657
let rv = mp4parse_get_track_video_info(context, track, &mut video);
5758
if rv == mp4parse_error::MP4PARSE_OK {

mp4parse_capi/src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub struct mp4parse_track_audio_info {
141141
// TODO(kinetik):
142142
// int32_t profile;
143143
// int32_t extended_profile; // check types
144-
codec_specific_config: mp4parse_byte_data,
144+
pub codec_specific_config: mp4parse_byte_data,
145145
}
146146

147147
#[repr(C)]
@@ -150,9 +150,7 @@ pub struct mp4parse_track_video_info {
150150
pub display_height: u32,
151151
pub image_width: u16,
152152
pub image_height: u16,
153-
// TODO(kinetik):
154-
// extra_data
155-
// codec_specific_config
153+
pub extra_data: mp4parse_byte_data,
156154
}
157155

158156
#[repr(C)]
@@ -547,6 +545,13 @@ pub unsafe extern fn mp4parse_get_track_video_info(parser: *mut mp4parse_parser,
547545
(*info).image_width = video.width;
548546
(*info).image_height = video.height;
549547

548+
match video.codec_specific {
549+
VideoCodecSpecific::AVCConfig(ref avc) => {
550+
(*info).extra_data.set_data(avc);
551+
},
552+
_ => {},
553+
}
554+
550555
MP4PARSE_OK
551556
}
552557

@@ -737,6 +742,7 @@ fn arg_validation() {
737742
display_height: 0,
738743
image_width: 0,
739744
image_height: 0,
745+
extra_data: mp4parse_byte_data::default(),
740746
};
741747
assert_eq!(MP4PARSE_ERROR_BADARG, mp4parse_get_track_video_info(std::ptr::null_mut(), 0, &mut dummy_video));
742748

@@ -781,6 +787,7 @@ fn arg_validation_with_parser() {
781787
display_height: 0,
782788
image_width: 0,
783789
image_height: 0,
790+
extra_data: mp4parse_byte_data::default(),
784791
};
785792
assert_eq!(MP4PARSE_ERROR_BADARG, mp4parse_get_track_video_info(parser, 0, &mut dummy_video));
786793

@@ -852,6 +859,7 @@ fn arg_validation_with_data() {
852859
display_height: 0,
853860
image_width: 0,
854861
image_height: 0,
862+
extra_data: mp4parse_byte_data::default(),
855863
};
856864
assert_eq!(MP4PARSE_OK, mp4parse_get_track_video_info(parser, 0, &mut video));
857865
assert_eq!(video.display_width, 320);
@@ -883,7 +891,8 @@ fn arg_validation_with_data() {
883891
let mut video = mp4parse_track_video_info { display_width: 0,
884892
display_height: 0,
885893
image_width: 0,
886-
image_height: 0 };
894+
image_height: 0,
895+
extra_data: mp4parse_byte_data::default(),};
887896
assert_eq!(MP4PARSE_ERROR_BADARG, mp4parse_get_track_video_info(parser, 3, &mut video));
888897
assert_eq!(video.display_width, 0);
889898
assert_eq!(video.display_height, 0);

0 commit comments

Comments
 (0)