解决冲突

Signed-off-by: cailei <cailei24@huawei.com>
This commit is contained in:
cailei 2023-04-26 17:12:54 +08:00
parent aed543404e
commit f430c3419e
6 changed files with 126 additions and 3 deletions

View File

@ -43,5 +43,5 @@ ohos_shared_library("av_codec_plugin_FFmpegMuxer") {
relative_install_dir = "media/av_codec_plugins"
subsystem_name = "multimedia"
part_name = "multimedia_av_codec"
part_name = "av_codec"
}

View File

@ -35,14 +35,21 @@ constexpr uint32_t DEFAULT_FRAME_COUNT = 1;
} // namespace
static void OnError(OH_AVCodec *codec, int32_t errorCode, void *userData) {
(void)codec;
(void)errorCode;
(void)userData;
cout << "Error received, errorCode:" << errorCode << endl;
}
static void OnOutputFormatChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData) {
(void)codec;
(void)format;
(void)userData;
cout << "OnOutputFormatChanged received" << endl;
}
static void OnInputBufferAvailable(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData) {
(void)codec;
ADecSignal *signal_ = static_cast<ADecSignal *>(userData);
cout << "OnInputBufferAvailable received, index:" << index << endl;
unique_lock<mutex> lock(signal_->inMutex_);
@ -53,6 +60,7 @@ static void OnInputBufferAvailable(OH_AVCodec *codec, uint32_t index, OH_AVMemor
static void OnOutputBufferAvailable(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr,
void *userData) {
(void)codec;
ADecSignal *signal_ = static_cast<ADecSignal *>(userData);
cout << "OnOutputBufferAvailable received, index:" << index << endl;
unique_lock<mutex> lock(signal_->outMutex_);

View File

@ -35,14 +35,21 @@ constexpr uint32_t DEFAULT_FRAME_COUNT = 1;
} // namespace
static void OnError(OH_AVCodec *codec, int32_t errorCode, void *userData) {
(void)codec;
(void)errorCode;
(void)userData;
cout << "Error received, errorCode:" << errorCode << endl;
}
static void OnOutputFormatChanged(OH_AVCodec *codec, OH_AVFormat *format, void *userData) {
(void)codec;
(void)format;
(void)userData;
cout << "OnOutputFormatChanged received" << endl;
}
static void OnInputBufferAvailable(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData) {
(void)codec;
AEncSignal *signal_ = static_cast<AEncSignal *>(userData);
cout << "OnInputBufferAvailable received, index:" << index << endl;
unique_lock<mutex> lock(signal_->inMutex_);
@ -53,6 +60,7 @@ static void OnInputBufferAvailable(OH_AVCodec *codec, uint32_t index, OH_AVMemor
static void OnOutputBufferAvailable(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr,
void *userData) {
(void)codec;
AEncSignal *signal_ = static_cast<AEncSignal *>(userData);
cout << "OnOutputBufferAvailable received, index:" << index << endl;
unique_lock<mutex> lock(signal_->outMutex_);

View File

@ -226,6 +226,7 @@ void ADecDemoCallback::OnError(AVCodecErrorType errorType, int32_t errorCode)
void ADecDemoCallback::OnOutputFormatChanged(const Format &format)
{
(void)format;
cout << "OnOutputFormatChanged received" << endl;
}
@ -239,6 +240,8 @@ void ADecDemoCallback::OnInputBufferAvailable(uint32_t index)
void ADecDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag)
{
(void)info;
(void)flag;
cout << "OnOutputBufferAvailable received, index:" << index << endl;
unique_lock<mutex> lock(signal_->outMutex_);
signal_->outQueue_.push(index);

View File

@ -15,16 +15,88 @@
#include <climits>
#include <iostream>
#include <thread>
#include <vector>
#include "avmuxer_demo.h"
#include "avmuxer_ffmpeg_demo.h"
#include "avmuxer_engine_demo.h"
#include "avcodec_audio_encoder_inner_demo.h"
#include "avcodec_audio_decoder_demo.h"
#include "avcodec_audio_encoder_demo.h"
using namespace OHOS;
using namespace OHOS::Media;
using namespace OHOS::Media::Plugin;
using namespace OHOS::Media::AudioDemo;
using namespace OHOS::Media::InnerAudioDemo;
using namespace std;
constexpr int RUN_TIME = 600;
extern "C" {
extern int NativeSelectMode();
extern int RunNativeMuxer(const char *out);
}
static int RunLoopNativeMuxer(string out)
{
time_t startTime = time(NULL);
time_t curTime = time(NULL);
while (difftime(curTime, startTime) < RUN_TIME) {
RunNativeMuxer(out.c_str());
time(&curTime);
}
return 0;
}
static int RunAVMuxer()
{
auto avmuxer = std::make_unique<AVMuxerDemo>();
if (avmuxer == nullptr) {
cout << "avmuxer is null" << endl;
return 0;
}
avmuxer->RunCase();
cout << "demo avmuxer end" << endl;
return 0;
}
static int RunAVMuxerWithMultithread()
{
auto avmuxer = std::make_unique<AVMuxerDemo>();
if (avmuxer == nullptr) {
cout << "avmuxer is null" << endl;
return 0;
}
avmuxer->RunMultiThreadCase();
cout << "demo multi thread avmuxer end" << endl;
return 0;
}
static int RunFfmpegMuxer()
{
std::unique_ptr<AVMuxerDemoBase> ffmpegMuxer = std::make_unique<AVMuxerFFmpegDemo>();
if (ffmpegMuxer == nullptr) {
cout << "ffmpegMuxer is null" << endl;
return 0;
}
ffmpegMuxer->RunCase();
cout << "demo ffmpegMuxer end" << endl;
return 0;
}
static int RunEngineMuxer()
{
std::unique_ptr<AVMuxerDemoBase> muxer = std::make_unique<AVMuxerEngineDemo>();
if (muxer == nullptr) {
cout << "AVMuxerEngineDemo is null" << endl;
return 0;
}
muxer->RunCase();
cout << "demo engine demo end" << endl;
return 0;
}
static int RunAudioDecoder()
{
auto audioEnc = std::make_unique<ADecDemo>();
@ -85,6 +157,13 @@ int main(int argc, char *argv[])
cout << "1:Audio Encoder" << endl;
cout << "2:Audio Inner Decoder" << endl;
cout << "3:Audio Inner Encoder" << endl;
cout << "4:native_muxer" << endl;
cout << "5:native_muxer loop" << endl;
cout << "6:native_muxer multithread" << endl;
cout << "7:inner_muxer" << endl;
cout << "8:inner_muxer with multithread write" << endl;
cout << "9:ffmpeg_muxer" << endl;
cout << "10:engine_muxer" << endl;
string mode;
(void)getline(cin, mode);
@ -96,7 +175,32 @@ int main(int argc, char *argv[])
(void)RunAudioInnerDecoder();
} else if (mode == "3") {
(void)RunAudioInnerEncoder();
} else {
} else if (mode == "4") {
NativeSelectMode();
RunNativeMuxer("native_mux");
} else if (mode == "5") {
NativeSelectMode();
RunLoopNativeMuxer("loop_native_mux");
} else if (mode == "6") {
NativeSelectMode();
vector<thread> vecThread;
for (int i = 0; i < 10; ++i) {
string out = to_string(i + 1);
out += "_native_mux";
vecThread.push_back(thread(RunLoopNativeMuxer, out));
}
for (int i = 0; i < 10; ++i) {
vecThread[i].join();
}
} else if (mode == "7") {
RunAVMuxer();
} else if (mode == "8") {
RunAVMuxerWithMultithread();
} else if (mode == "9") {
RunFfmpegMuxer();
} else if (mode == "10") {
RunEngineMuxer();
} else {
cout << "no that selection" << endl;
}
return 0;

View File

@ -60,7 +60,7 @@ ohos_unittest("av_muxer_unit_test") {
}
external_deps = [
"multimedia_av_codec:av_codec_client",
"av_codec:av_codec_client",
]
resource_config_file = "$AV_CODE_ROOT_DIR/test/unittest/ohos_test.xml"