android Codec-specific data
在CCodec中,CCodecBufferChannel::onWorkDone
回调的时候处理csd buffer
void CCodecBufferChannel::onWorkDone(
std::unique_ptr<C2Work> work, const sp<AMessage> &outputFormat,
const C2StreamInitDataInfo::output *initData) {
if (handleWork(std::move(work), outputFormat, initData)) {
feedInputBufferIfAvailable();
}
}
在C2Config.h中有csd的注释,csd是用来初始化codec的,在AVC/HEVC中,由SPS/PPS/VPS组成。
codec2/core/include/C2Config.h
/**
* Codec-specific initialization data.
*
* This is initialization data for the codec.
*
* For AVC/HEVC, these are the concatenated SPS/PPS/VPS NALs.
*
* TODO: define for other codecs.
*/
typedef C2StreamParam<C2Info, C2BlobValue, kParamIndexInitData> C2StreamInitDataInfo;
constexpr char C2_PARAMKEY_INIT_DATA[] = "coded.init-data";
codec2play中获取csd数据
sp<AMessage> format;
(void) convertMetaDataToMessage(source->getFormat(), &format);
sp<ABuffer> csd0, csd1;
format->findBuffer("csd-0", &csd0);
format->findBuffer("csd-1", &csd1);
运行后从log中可以看到输出如下,csd里面包含了这些meta信息,log输出可以通过format->debugString().c_str()
实现:
AMessage(what = 0x00000000) = {
string mime = "video/avc"
int64_t durationUs = 5240000
int32_t frame-count = 131
string language = "und"
int32_t width = 1920
int32_t height = 1080
int32_t display-width = 1920
int32_t display-height = 1080
int32_t rotation-degrees = 0
int32_t max-input-size = 1555201
int32_t frame-rate = 25
int32_t profile = 8
int32_t level = 2048
Buffer csd-0 = {
00000000: 00 00 00 01 67 64 00 28 ac d9 40 78 02 27 e5 84 ....gd.(..@x.'..
00000010: 00 00 03 00 04 00 00 03 00 c8 3c 60 c6 58 ..........<`.X
}
Buffer csd-1 = {
00000000: 00 00 00 01 68 eb e3 cb 22 c0 ....h...".
}
string file-format = "video/mp4"
}