graph TD A["ExecutePlay(napi_init.cpp)"] -->|传入SampleInfo参数| B["RunSample(sample_helper.cpp)"] B --- |根据SampleType创建Sample| C["SampleFactory::CreateSample(sample_base.cpp)"] C --- |SampleType=VIDEO_SAMPLE| D("VideoSampleBase(2个子类)") C --> |SampleType=YUV_VIEWER|E("YuvViewer") D --> F["VSB.Init"] D --> P["VSB.Start"] D --> Q["SampleBase.WaitForSampleDone"] E -->R1["YuvViewer.Init"] E -->R2["YuvViewer.Start"] E -->Q["SampleBase.WaitForSampleDone"]
graph TD A["SampleBase(sample_base.cpp)"] -->B["VideoSampleBase(video_sample_base.cpp)"] B --> C["VideoEncoderSample"] B --> D["VideoDecoderSample"] A --> E["YuvViewer"] classDef inherit fill:#2196F3,stroke:#1976D2,stroke-width:2px; class A,B,C,D,E inherit
调用链图2——VSB.Init
1 2 3 4 5 6 7 8 9
graph TD F["VSB.Init"] F -->|根据sampleinfo.dataProducerInfo.dataProducerType创建dataProducer并初始化| G("DataProducerFactory::CreateDataProducer(3种)") G -->|这里创建Demuxer| H["dataProducer->Init"] F --> I["VSB/VDS.CreateWindow"] I -->|VDS会根据codecRunMode、codecConsumerType创建不同窗口| Z["WindowManager::GetInstance().CreateWindowWrapper"] F --> J["VSB.InitVideoCodec"] F -->|初始化context->in\outputBufferQueue| O["VXS.CreateSampleBufferQueue"]
graph TD B["DataProducerBase(data_producer_base.cpp)"] B --> C["BitStreamReader"] B --> D["Demuxer"] B --> E["RawdataReader"] F["VideoCodecBase(video_codec_base.cpp)"] F --> G["VideoDecoder"] F --> H["VideoEncoder"] G --- I["VideoDecoderAPI{10/11}"] I --- J["VideoDecoderAPI{10/11}Buffer"] I --- K["VideoDecoderAPI{10/11}Surface"] classDef inherit fill:#2196F3,stroke:#1976D2,stroke-width:2px; class B,C,D,E,F,G,H,I,J,K inherit
!!! note “注”
上图VideoEncoder向下继承关系和VideoDecoder同理。
调用链图3——VSB.Start
接调用链图1中VSB.Start
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
graph TD A["VSB.Start"] --> B["VX->Start"] A -->|更新帧信息| C["VX->UpdatePictureInfo"] A -->|启动输入/输出线程| D["VXS.StartLoop"] B --- E["OH_Video{En/De}coder_Start"] C --- F["GetFormat"] F --- F1["OH_VideoDecoder_GetOutputDescription"] D --- |解码| G1["VDS.StartLoop"] D --- |编码| G2["VES.StartLoop"] G1 --- G11["VDS.InputThread"] G1 --- G12["VDS.OutputThread"] G2 --- G21["VES.{Surface/Buffer}InputThread"] G2 --- G22["VES.OutputThread"]
classDef libfunc fill:#4CAF50,stroke:#388E3C,stroke-width:2px; class E libfunc class F1 libfunc
end C4 ---|API11Surface| Z41["OH_VD_RenderOutputBuffer"] C4 ---|API11Buffer| Z42["OH_VD_FreeOutputBuffer"] C4 ---|API10Surface| Z43["OH_VD_RenderOutputData(弃用)"] C4 ---|API10Buffer| Z44["OH_VD_FreeOutputData(弃用)"] A --- B["AVCodecTrace::TraceEnd"] A --- D["AVCodecTrace::CounterTrace"] A --- E["SampleBase.NotifySampleDone"] B --- B1["OH_HiTrace_FinishAsyncTrace"] D --- D1["OH_HiTrace_CountTrace"]
classDef libfunc fill:#4CAF50,stroke:#388E3C,stroke-width:2px; class Z libfunc class B1 libfunc class D1 libfunc class Z41 libfunc class Z42 libfunc class Z43 libfunc class Z44 libfunc
YuvViewer调用链
核心功能是将内存中的 YUV 原始数据通过图形窗口渲染为人类可理解的图像
1 2 3 4 5 6 7 8
graph TD A["YuvViewer"] --- B["YuvViewer.Init"] A --- C["YuvViewer.Start"] A --- D["YueViewer.WaitForSampleDone"] B --- E["DataProducerFactory::CreateDataProducer(3种)"] E --- F["dataProducer.Init"] B --- G["CreateWindow"] C --- H["InputThread"]