1 /*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <string>
17 #include <sys/stat.h>
18 #include <fcntl.h>
19 #include <cinttypes>
20 #include <map>
21 #include "gtest/gtest.h"
22 #include "avcodec_errors.h"
23 #include "avcodec_audio_common.h"
24 #include "avcodec_info.h"
25 #include "avcodec_audio_channel_layout.h"
26 #include "avcodec_mime_type.h"
27 #include "media_description.h"
28 #include "file_server_demo.h"
29 #include "avsource_unit_test.h"
30
31 #define LOCAL true
32 #define URI false
33
34 using namespace OHOS;
35 using namespace OHOS::MediaAVCodec;
36 using namespace testing::ext;
37 using namespace std;
38
39 namespace {
40 unique_ptr<FileServerDemo> server = nullptr;
41 static const string TEST_FILE_PATH = "/data/test/media/";
42 static const string TEST_URI_PATH = "http://127.0.0.1:46666/";
43 const std::string HEVC_LIB_PATH = std::string(AV_CODEC_PATH) + "/libav_codec_hevc_parser.z.so";
44 const int64_t SOURCE_OFFSET = 0;
45 string g_hdrVividPath = TEST_FILE_PATH + string("hdrvivid_720p_2s.mp4");
46 string g_hdrVividUri = TEST_URI_PATH + string("hdrvivid_720p_2s.mp4");
47 string g_mp4HevcPath = TEST_FILE_PATH + string("camera_h265_aac_rotate270.mp4");
48 string g_mp4HevcdUri = TEST_URI_PATH + string("camera_h265_aac_rotate270.mp4");
49 string g_mkvHevcAccPath = TEST_FILE_PATH + string("h265_aac_4sec.mkv");
50 string g_mkvHevcAccUri = TEST_URI_PATH + string("h265_aac_4sec.mkv");
51 string g_mkvAvcOpusPath = TEST_FILE_PATH + string("h264_opus_4sec.mkv");
52 string g_mkvAvcOpusUri = TEST_URI_PATH + string("h264_opus_4sec.mkv");
53 string g_mkvAvcMp3Path = TEST_FILE_PATH + string("h264_mp3_4sec.mkv");
54 string g_mkvAvcMp3Uri = TEST_URI_PATH + string("h264_mp3_4sec.mkv");
55
56 std::map<std::string, std::map<std::string, int32_t>> infoMap = {
57 {"hdrVivid", {
58 {"profile", static_cast<int32_t>(OH_HEVCProfile::HEVC_PROFILE_MAIN_10)},
59 {"level", static_cast<int32_t>(HEVCLevel::HEVC_LEVEL_4)},
60 {"colorRange", 0}, {"colorMatrix", static_cast<int32_t>(OH_MatrixCoefficient::MATRIX_COEFFICIENT_BT2020_NCL)},
61 {"colorTrans", static_cast<int32_t>(OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_HLG)},
62 {"colorPrim", static_cast<int32_t>(OH_ColorPrimary::COLOR_PRIMARY_BT2020)},
63 {"chromaLoc", static_cast<int32_t>(ChromaLocation::CHROMA_LOC_LEFT)},
64 }},
65 {"mp4Hevc", {
66 {"profile", static_cast<int32_t>(OH_HEVCProfile::HEVC_PROFILE_MAIN)},
67 {"level", static_cast<int32_t>(HEVCLevel::HEVC_LEVEL_31)},
68 {"colorRange", 0}, {"colorMatrix", static_cast<int32_t>(OH_MatrixCoefficient::MATRIX_COEFFICIENT_BT709)},
69 {"colorTrans", static_cast<int32_t>(OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_BT709)},
70 {"colorPrim", static_cast<int32_t>(OH_ColorPrimary::COLOR_PRIMARY_BT709)},
71 {"chromaLoc", static_cast<int32_t>(ChromaLocation::CHROMA_LOC_LEFT)},
72 }},
73 {"mkvHevcAcc", {
74 {"profile", static_cast<int32_t>(OH_HEVCProfile::HEVC_PROFILE_MAIN)},
75 {"level", static_cast<int32_t>(HEVCLevel::HEVC_LEVEL_41)},
76 {"colorRange", 0}, {"colorMatrix", static_cast<int32_t>(OH_MatrixCoefficient::MATRIX_COEFFICIENT_UNSPECIFIED)},
77 {"colorTrans", static_cast<int32_t>(OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_UNSPECIFIED)},
78 {"colorPrim", static_cast<int32_t>(OH_ColorPrimary::COLOR_PRIMARY_UNSPECIFIED)},
79 {"chromaLoc", static_cast<int32_t>(ChromaLocation::CHROMA_LOC_LEFT)},
80 }}
81 };
82 } // namespace
83
InitResource(const std::string & path,bool local)84 void AVSourceUnitTest::InitResource(const std::string &path, bool local)
85 {
86 printf("---- %s ------\n", path.c_str());
87 if (local) {
88 fd_ = OpenFile(path);
89 int64_t size = GetFileSize(path);
90 source_ = AVSourceMockFactory::CreateSourceWithFD(fd_, SOURCE_OFFSET, size);
91 ASSERT_NE(source_, nullptr);
92 } else {
93 source_ = AVSourceMockFactory::CreateSourceWithURI(const_cast<char*>(path.data()));
94 ASSERT_NE(source_, nullptr);
95 }
96 format_ = source_->GetSourceFormat();
97 ASSERT_NE(format_, nullptr);
98 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_COUNT, streamsCount_));
99 for (int i = 0; i < streamsCount_; i++) {
100 format_ = source_->GetTrackFormat(i);
101 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
102 if (formatVal_.trackType == MediaType::MEDIA_TYPE_VID) {
103 vTrackIdx_ = i;
104 } else if (formatVal_.trackType == MediaType::MEDIA_TYPE_AUD) {
105 aTrackIdx_ = i;
106 }
107 }
108 }
109
CheckHevcInfo(const std::string resName)110 void AVSourceUnitTest::CheckHevcInfo(const std::string resName)
111 {
112 for (int i = 0; i < streamsCount_; i++) {
113 format_ = source_->GetTrackFormat(i);
114 string codecMime;
115 format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, codecMime);
116 if (codecMime == AVCodecMimeType::MEDIA_MIMETYPE_VIDEO_HEVC) {
117 printf("[trackFormat %d]: %s\n", i, format_->DumpInfo());
118 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_PROFILE, formatVal_.profile));
119 ASSERT_EQ(formatVal_.profile, infoMap[resName]["profile"]);
120 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_COLOR_PRIMARIES, formatVal_.colorPri));
121 ASSERT_EQ(formatVal_.colorPri, infoMap[resName]["colorPrim"]);
122 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRANSFER_CHARACTERISTICS,
123 formatVal_.colorTrans));
124 ASSERT_EQ(formatVal_.colorTrans, infoMap[resName]["colorTrans"]);
125 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_MATRIX_COEFFICIENTS, formatVal_.colorMatrix));
126 ASSERT_EQ(formatVal_.colorMatrix, infoMap[resName]["colorMatrix"]);
127 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_RANGE_FLAG, formatVal_.colorRange));
128 ASSERT_EQ(formatVal_.colorRange, infoMap[resName]["colorRange"]);
129 #ifdef AVSOURCE_INNER_UNIT_TEST
130 printf("-------input inner--------\n");
131 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_CHROMA_LOCATION, formatVal_.chromaLoc));
132 ASSERT_EQ(formatVal_.chromaLoc, infoMap[resName]["chromaLoc"]);
133 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_LEVEL, formatVal_.level));
134 ASSERT_EQ(formatVal_.level, infoMap[resName]["level"]);
135 #endif
136 if (resName == "hdrVivid") {
137 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_VIDEO_IS_HDR_VIVID,
138 formatVal_.isHdrVivid));
139 printf("isHdrVivid = %d\n", formatVal_.isHdrVivid);
140 ASSERT_EQ(formatVal_.isHdrVivid, 1);
141 } else {
142 ASSERT_FALSE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_VIDEO_IS_HDR_VIVID,
143 formatVal_.isHdrVivid));
144 }
145 }
146 }
147 }
148
149 namespace {
150 /**
151 * @tc.name: AVSource_GetFormat_1190
152 * @tc.desc: get HDRVivid format, local
153 * @tc.type: FUNC
154 */
155 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1190, TestSize.Level1)
156 {
157 if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
158 return;
159 }
160 InitResource(g_hdrVividPath, LOCAL);
161 ASSERT_NE(source_, nullptr);
162 CheckHevcInfo("hdrVivid");
163 }
164
165 /**
166 * @tc.name: AVSource_GetFormat_1120
167 * @tc.desc: get HDRVivid format, uri
168 * @tc.type: FUNC
169 */
170 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1120, TestSize.Level1)
171 {
172 if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
173 return;
174 }
175 InitResource(g_hdrVividUri, URI);
176 ASSERT_NE(source_, nullptr);
177 CheckHevcInfo("hdrVivid");
178 }
179
180 /**
181 * @tc.name: AVSource_GetFormat_1200
182 * @tc.desc: get mp4 265 format, local
183 * @tc.type: FUNC
184 */
185 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1200, TestSize.Level1)
186 {
187 if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
188 return;
189 }
190 InitResource(g_mp4HevcPath, LOCAL);
191 ASSERT_NE(source_, nullptr);
192 CheckHevcInfo("mp4Hevc");
193 }
194
195 /**
196 * @tc.name: AVSource_GetFormat_1201
197 * @tc.desc: get mp4 265 format, uri
198 * @tc.type: FUNC
199 */
200 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1201, TestSize.Level1)
201 {
202 if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
203 return;
204 }
205 InitResource(g_mp4HevcdUri, URI);
206 ASSERT_NE(source_, nullptr);
207 CheckHevcInfo("mp4Hevc");
208 }
209
210 /**
211 * @tc.name: AVSource_GetFormat_1300
212 * @tc.desc: get mkv 265 aac format, local
213 * @tc.type: FUNC
214 */
215 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1300, TestSize.Level1)
216 {
217 if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
218 return;
219 }
220 InitResource(g_mkvHevcAccPath, LOCAL);
221 ASSERT_NE(source_, nullptr);
222 CheckHevcInfo("mkvHevcAcc");
223 }
224
225 /**
226 * @tc.name: AVSource_GetFormat_1303
227 * @tc.desc: get mkv 265 aac format, uri
228 * @tc.type: FUNC
229 */
230 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1303, TestSize.Level1)
231 {
232 if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) {
233 return;
234 }
235 InitResource(g_mkvHevcAccUri, URI);
236 ASSERT_NE(source_, nullptr);
237 CheckHevcInfo("mkvHevcAcc");
238 }
239
240 /**
241 * @tc.name: AVSource_GetFormat_1301
242 * @tc.desc: get mkv 264 opus format, local
243 * @tc.type: FUNC
244 */
245 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1301, TestSize.Level1)
246 {
247 InitResource(g_mkvAvcOpusPath, LOCAL);
248 trackIndex_ = vTrackIdx_;
249 format_ = source_->GetTrackFormat(trackIndex_);
250 ASSERT_NE(format_, nullptr);
251 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
252 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
253 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_WIDTH, formatVal_.width));
254 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, formatVal_.height));
255 ASSERT_TRUE(format_->GetDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, formatVal_.frameRate));
256 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
257 ASSERT_EQ(formatVal_.codecMime, "video/avc");
258 ASSERT_EQ(formatVal_.width, 1920);
259 ASSERT_EQ(formatVal_.height, 1080);
260 ASSERT_EQ(formatVal_.frameRate, 60.000000);
261 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_VID);
262 trackIndex_ = aTrackIdx_;
263 format_ = source_->GetTrackFormat(trackIndex_);
264 ASSERT_NE(format_, nullptr);
265 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
266 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_AUDIO_SAMPLE_FORMAT, formatVal_.audioSampleFormat));
267 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_SAMPLE_RATE, formatVal_.sampleRate));
268 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
269 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_CHANNEL_COUNT, formatVal_.channelCount));
270 ASSERT_TRUE(format_->GetLongValue(MediaDescriptionKey::MD_KEY_CHANNEL_LAYOUT, formatVal_.channelLayout));
271 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
272 ASSERT_EQ(formatVal_.channelLayout, static_cast<int64_t>(AudioChannelLayout::MONO));
273 ASSERT_EQ(formatVal_.sampleRate, 48000);
274 ASSERT_EQ(formatVal_.codecMime, "audio/opus");
275 ASSERT_EQ(formatVal_.channelCount, 1);
276 ASSERT_EQ(formatVal_.audioSampleFormat, AudioSampleFormat::SAMPLE_F32P);
277 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_AUD);
278 }
279
280 /**
281 * @tc.name: AVSource_GetFormat_1302
282 * @tc.desc: get mkv 264 mp3 format, local
283 * @tc.type: FUNC
284 */
285 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1302, TestSize.Level1)
286 {
287 InitResource(g_mkvAvcMp3Path, LOCAL);
288 trackIndex_ = vTrackIdx_;
289 format_ = source_->GetTrackFormat(trackIndex_);
290 ASSERT_NE(format_, nullptr);
291 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
292 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
293 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_WIDTH, formatVal_.width));
294 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, formatVal_.height));
295 ASSERT_TRUE(format_->GetDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, formatVal_.frameRate));
296 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
297 ASSERT_EQ(formatVal_.codecMime, "video/avc");
298 ASSERT_EQ(formatVal_.width, 1920);
299 ASSERT_EQ(formatVal_.height, 1080);
300 ASSERT_EQ(formatVal_.frameRate, 60.000000);
301 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_VID);
302 trackIndex_ = aTrackIdx_;
303 format_ = source_->GetTrackFormat(trackIndex_);
304 ASSERT_NE(format_, nullptr);
305 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
306 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_AUDIO_SAMPLE_FORMAT, formatVal_.audioSampleFormat));
307 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_SAMPLE_RATE, formatVal_.sampleRate));
308 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
309 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_CHANNEL_COUNT, formatVal_.channelCount));
310 ASSERT_TRUE(format_->GetLongValue(MediaDescriptionKey::MD_KEY_CHANNEL_LAYOUT, formatVal_.channelLayout));
311 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
312 ASSERT_EQ(formatVal_.channelLayout, static_cast<int64_t>(AudioChannelLayout::STEREO));
313 ASSERT_EQ(formatVal_.sampleRate, 44100);
314 ASSERT_EQ(formatVal_.codecMime, "audio/mpeg");
315 ASSERT_EQ(formatVal_.channelCount, 2);
316 ASSERT_EQ(formatVal_.audioSampleFormat, AudioSampleFormat::SAMPLE_F32P);
317 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_AUD);
318 }
319
320 /**
321 * @tc.name: AVSource_GetFormat_1304
322 * @tc.desc: get mkv 264 opus format, uri
323 * @tc.type: FUNC
324 */
325 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1304, TestSize.Level1)
326 {
327 InitResource(g_mkvAvcOpusUri, URI);
328 trackIndex_ = vTrackIdx_;
329 format_ = source_->GetTrackFormat(trackIndex_);
330 ASSERT_NE(format_, nullptr);
331 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
332 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
333 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_WIDTH, formatVal_.width));
334 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, formatVal_.height));
335 ASSERT_TRUE(format_->GetDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, formatVal_.frameRate));
336 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
337 ASSERT_EQ(formatVal_.codecMime, "video/avc");
338 ASSERT_EQ(formatVal_.width, 1920);
339 ASSERT_EQ(formatVal_.height, 1080);
340 ASSERT_EQ(formatVal_.frameRate, 60.000000);
341 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_VID);
342 trackIndex_ = aTrackIdx_;
343 format_ = source_->GetTrackFormat(trackIndex_);
344 ASSERT_NE(format_, nullptr);
345 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
346 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_AUDIO_SAMPLE_FORMAT, formatVal_.audioSampleFormat));
347 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_SAMPLE_RATE, formatVal_.sampleRate));
348 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
349 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_CHANNEL_COUNT, formatVal_.channelCount));
350 ASSERT_TRUE(format_->GetLongValue(MediaDescriptionKey::MD_KEY_CHANNEL_LAYOUT, formatVal_.channelLayout));
351 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
352 ASSERT_EQ(formatVal_.channelLayout, static_cast<int64_t>(AudioChannelLayout::MONO));
353 ASSERT_EQ(formatVal_.sampleRate, 48000);
354 ASSERT_EQ(formatVal_.codecMime, "audio/opus");
355 ASSERT_EQ(formatVal_.channelCount, 1);
356 ASSERT_EQ(formatVal_.audioSampleFormat, AudioSampleFormat::SAMPLE_F32P);
357 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_AUD);
358 }
359
360 /**
361 * @tc.name: AVSource_GetFormat_1305
362 * @tc.desc: get mkv 264 mp3 format, uri
363 * @tc.type: FUNC
364 */
365 HWTEST_F(AVSourceUnitTest, AVSource_GetFormat_1305, TestSize.Level1)
366 {
367 InitResource(g_mkvAvcMp3Uri, URI);
368 trackIndex_ = vTrackIdx_;
369 format_ = source_->GetTrackFormat(trackIndex_);
370 ASSERT_NE(format_, nullptr);
371 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
372 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
373 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_WIDTH, formatVal_.width));
374 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_HEIGHT, formatVal_.height));
375 ASSERT_TRUE(format_->GetDoubleValue(MediaDescriptionKey::MD_KEY_FRAME_RATE, formatVal_.frameRate));
376 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
377 ASSERT_EQ(formatVal_.codecMime, "video/avc");
378 ASSERT_EQ(formatVal_.width, 1920);
379 ASSERT_EQ(formatVal_.height, 1080);
380 ASSERT_EQ(formatVal_.frameRate, 60.000000);
381 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_VID);
382 trackIndex_ = aTrackIdx_;
383 format_ = source_->GetTrackFormat(trackIndex_);
384 ASSERT_NE(format_, nullptr);
385 printf("[trackFormat %d]: %s\n", trackIndex_, format_->DumpInfo());
386 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_AUDIO_SAMPLE_FORMAT, formatVal_.audioSampleFormat));
387 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_SAMPLE_RATE, formatVal_.sampleRate));
388 ASSERT_TRUE(format_->GetStringValue(MediaDescriptionKey::MD_KEY_CODEC_MIME, formatVal_.codecMime));
389 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_CHANNEL_COUNT, formatVal_.channelCount));
390 ASSERT_TRUE(format_->GetLongValue(MediaDescriptionKey::MD_KEY_CHANNEL_LAYOUT, formatVal_.channelLayout));
391 ASSERT_TRUE(format_->GetIntValue(MediaDescriptionKey::MD_KEY_TRACK_TYPE, formatVal_.trackType));
392 ASSERT_EQ(formatVal_.channelLayout, static_cast<int64_t>(AudioChannelLayout::STEREO));
393 ASSERT_EQ(formatVal_.sampleRate, 44100);
394 ASSERT_EQ(formatVal_.codecMime, "audio/mpeg");
395 ASSERT_EQ(formatVal_.channelCount, 2);
396 ASSERT_EQ(formatVal_.audioSampleFormat, AudioSampleFormat::SAMPLE_F32P);
397 ASSERT_EQ(formatVal_.trackType, MediaType::MEDIA_TYPE_AUD);
398 }
399 } // namespace