diff --git a/frameworks/native/avmuxer/avmuxer_impl.cpp b/frameworks/native/avmuxer/avmuxer_impl.cpp index fb3d34951..1a4861c31 100644 --- a/frameworks/native/avmuxer/avmuxer_impl.cpp +++ b/frameworks/native/avmuxer/avmuxer_impl.cpp @@ -33,14 +33,14 @@ namespace Media { std::shared_ptr AVMuxerFactory::CreateAVMuxer(int32_t fd, AVOutputFormat format) { AVCodecTrace trace(std::string(__FUNCTION__)); - CHECK_AND_RETURN_RET_LOG((fcntl(fd, F_GETFL, 0) & O_RDWR) == O_RDWR, nullptr, "no permission to read and write fd"); - CHECK_AND_RETURN_RET_LOG(lseek(fd, 0, SEEK_CUR) != -1, nullptr, "the fd is not seekable"); + CHECK_AND_RETURN_RET_LOG((fcntl(fd, F_GETFL, 0) & O_RDWR) == O_RDWR, nullptr, "No permission to read and write fd"); + CHECK_AND_RETURN_RET_LOG(lseek(fd, 0, SEEK_CUR) != -1, nullptr, "The fd is not seekable"); std::shared_ptr impl = std::make_shared(fd, format); - CHECK_AND_RETURN_RET_LOG(impl != nullptr, nullptr, "create avmuxer implementation failed"); + CHECK_AND_RETURN_RET_LOG(impl != nullptr, nullptr, "Create avmuxer implementation failed"); int32_t ret = impl->Init(); - CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, nullptr, "init avmuxer implementation failed"); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, nullptr, "Init avmuxer implementation failed"); return impl; } @@ -64,7 +64,7 @@ int32_t AVMuxerImpl::Init() { AVCodecTrace trace(std::string(__FUNCTION__)); muxerClient_ = AVCodecServiceFactory::GetInstance().CreateMuxerService(); - CHECK_AND_RETURN_RET_LOG(muxerClient_ != nullptr, AVCS_ERR_INVALID_OPERATION, "create avmuxer engine failed"); + CHECK_AND_RETURN_RET_LOG(muxerClient_ != nullptr, AVCS_ERR_INVALID_OPERATION, "Create avmuxer engine failed"); return AVCS_ERR_OK; } @@ -110,14 +110,13 @@ int32_t AVMuxerImpl::WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffe CHECK_AND_RETURN_RET_LOG(sampleBuffer != nullptr && info.offset >= 0 && info.size >= 0, AVCS_ERR_INVALID_VAL, "Invalid memory"); - std::shared_ptr sharedSampleBuffer = - std::make_shared(info.size, AVSharedMemory::FLAGS_READ_ONLY, "sampleBuffer"); - int32_t ret = sharedSampleBuffer->Init(); - CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_NO_MEMORY, "create AVSharedMemoryBase failed"); + std::shared_ptr sharedSampleBuffer = + AVSharedMemoryBase::CreateFromLocal(info.size, AVSharedMemory::FLAGS_READ_ONLY, "SampleBuffer"); + CHECK_AND_RETURN_RET_LOG(sharedSampleBuffer == nullptr, AVCS_ERR_NO_MEMORY, "Create AVSharedMemoryBase failed"); errno_t rc = memcpy_s(sharedSampleBuffer->GetBase(), sharedSampleBuffer->GetSize(), sampleBuffer + info.offset, info.size); CHECK_AND_RETURN_RET_LOG(rc == EOK, AVCS_ERR_UNKNOWN, "memcpy_s failed"); - return muxerClient_->WriteSampleBuffer(trackIndex, sharedSampleBuffer->GetBase(), info); + return muxerClient_->WriteSampleBuffer(trackIndex, sharedSampleBuffer, info); } int32_t AVMuxerImpl::Stop() diff --git a/services/include/i_avmuxer.h b/services/include/i_avmuxer.h index 1bb465f89..85cb2e7b4 100644 --- a/services/include/i_avmuxer.h +++ b/services/include/i_avmuxer.h @@ -19,7 +19,8 @@ public: virtual int32_t SetParameter(const Format &generalFormat) = 0; virtual int32_t AddTrack(uint32_t &trackIndex, const Format &trackFormat) = 0; virtual int32_t Start() = 0; - virtual int32_t WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) = 0; + virtual int32_t WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, + AVCodecBufferInfo info) = 0; virtual int32_t Stop() = 0; }; } // namespace Media diff --git a/services/services/muxer/client/avmuxer_client.cpp b/services/services/muxer/client/avmuxer_client.cpp index c7c82c914..7e7a79028 100644 --- a/services/services/muxer/client/avmuxer_client.cpp +++ b/services/services/muxer/client/avmuxer_client.cpp @@ -95,10 +95,10 @@ int32_t AVMuxerClient::Start() return muxerProxy_->Start(); } -int32_t AVMuxerClient::WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) +int32_t AVMuxerClient::WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) { std::lock_guard lock(mutex_); - CHECK_AND_RETURN_RET_LOG(sampleBuffer != nullptr, AVCS_ERR_INVALID_VAL, "sampleBuffer is nullptr"); + CHECK_AND_RETURN_RET_LOG(sampleBuffer != nullptr, AVCS_ERR_INVALID_VAL, "SampleBuffer is nullptr"); CHECK_AND_RETURN_RET_LOG(muxerProxy_ != nullptr, AVCS_ERR_NO_MEMORY, "Muxer Service does not exist"); return muxerProxy_->WriteSampleBuffer(trackIndex, sampleBuffer, info); } diff --git a/services/services/muxer/client/include/avmuxer_client.h b/services/services/muxer/client/include/avmuxer_client.h index 0554f852e..9d2c49914 100644 --- a/services/services/muxer/client/include/avmuxer_client.h +++ b/services/services/muxer/client/include/avmuxer_client.h @@ -33,7 +33,7 @@ public: int32_t SetParameter(const Format &generalFormat) override; int32_t AddTrack(uint32_t &trackIndex, const Format &trackFormat) override; int32_t Start() override; - int32_t WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) override; + int32_t WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) override; int32_t Stop() override; void AVCodecServerDied(); diff --git a/services/services/muxer/ipc/avmuxer_proxy.cpp b/services/services/muxer/ipc/avmuxer_proxy.cpp index f17e7ebaf..797f958fa 100644 --- a/services/services/muxer/ipc/avmuxer_proxy.cpp +++ b/services/services/muxer/ipc/avmuxer_proxy.cpp @@ -44,10 +44,10 @@ int32_t AVMuxerProxy::DestroyStub() MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); - int error = Remote()->SendRequest(DESTROY_STUB, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call DestroyStub, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(DESTROY_STUB, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call DestroyStub"); return reply.ReadInt32(); } @@ -58,10 +58,10 @@ int32_t AVMuxerProxy::Init() MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); - int error = Remote()->SendRequest(INIT, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call Init, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(INIT, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call Init"); return reply.ReadInt32(); } @@ -72,12 +72,12 @@ int32_t AVMuxerProxy::SetLocation(float latitude, float longitude) MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); data.WriteFloat(latitude); data.WriteFloat(longitude); - int error = Remote()->SendRequest(SET_LOCATION, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call SetLocation, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(SET_LOCATION, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call SetLocation"); return reply.ReadInt32(); } @@ -88,11 +88,11 @@ int32_t AVMuxerProxy::SetRotation(int32_t rotation) MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); data.WriteInt32(rotation); - int error = Remote()->SendRequest(SET_ROTATION, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call SetRotation, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(SET_ROTATION, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call SetRotation"); return reply.ReadInt32(); } @@ -104,12 +104,11 @@ int32_t AVMuxerProxy::SetParameter(const Format &generalFormat) MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); AVCodecParcel::Marshalling(data, generalFormat); int32_t ret = Remote()->SendRequest(SET_PARAMETER, data, reply, option); - CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, - "SetParameter failed, error: %{public}d", ret); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, "SetParameter failed"); return reply.ReadInt32(); } @@ -121,14 +120,13 @@ int32_t AVMuxerProxy::AddTrack(uint32_t &trackIndex, const Format &trackFormat) MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); + data.WriteInt32(trackIndex); AVCodecParcel::Marshalling(data, trackFormat); - int32_t error = Remote()->SendRequest(ADD_TRACK, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call AddTrack, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(ADD_TRACK, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call AddTrack"); - // int32_t trackId = reply.ReadInt32(); - return reply.ReadInt32(); } @@ -139,17 +137,14 @@ int32_t AVMuxerProxy::Start() MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); - CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); + CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor"); - int32_t error = Remote()->SendRequest(START, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call Start, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(START, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call Start"); return reply.ReadInt32(); } - - - -int32_t AVMuxerProxy::WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) +int32_t AVMuxerProxy::WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) { CHECK_AND_RETURN_RET_LOG(sampleBuffer != nullptr, AVCS_ERR_INVALID_VAL, "sampleBuffer is nullptr"); MessageParcel data; @@ -157,11 +152,15 @@ int32_t AVMuxerProxy::WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuff MessageOption option; bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); - + data.WriteInt32(trackIndex); + WriteAVSharedMemoryToParcel(sampleBuffer, data); + data.WriteInt64(info.presentationTimeUs); + data.WriteInt32(info.size); + data.WriteInt32(info.offset); + // data.WriteInt32(info.flag); - - int32_t error = Remote()->SendRequest(WRITE_SAMPLE_BUFFER, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call WriteTrackSample, error: %{public}d", error); + int32_t ret = Remote()->SendRequest(WRITE_SAMPLE_BUFFER, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call WriteTrackSample"); return reply.ReadInt32(); } @@ -174,8 +173,8 @@ int32_t AVMuxerProxy::Stop() bool token = data.WriteInterfaceToken(AVMuxerProxy::GetDescriptor()); CHECK_AND_RETURN_RET_LOG(token, AVCS_ERR_INVALID_OPERATION, "Failed to write descriptor!"); - int error = Remote()->SendRequest(STOP, data, reply, option); - CHECK_AND_RETURN_RET_LOG(error == AVCS_ERR_OK, error, "Failed to call Stop, error: %{public}d", error); + int ret = Remote()->SendRequest(STOP, data, reply, option); + CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "Failed to call Stop"); return reply.ReadInt32(); } } // namespace Media diff --git a/services/services/muxer/ipc/avmuxer_stub.cpp b/services/services/muxer/ipc/avmuxer_stub.cpp index b54941500..ed5c8fb13 100644 --- a/services/services/muxer/ipc/avmuxer_stub.cpp +++ b/services/services/muxer/ipc/avmuxer_stub.cpp @@ -134,7 +134,7 @@ int32_t AVMuxerStub::Start() return muxerServer_->Start(); } -int32_t AVMuxerStub::WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) +int32_t AVMuxerStub::WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) { CHECK_AND_RETURN_RET_LOG(muxerServer_ != nullptr, AVCS_ERR_NO_MEMORY, "muxer service is nullptr"); return muxerServer_->WriteSampleBuffer(trackIndex, sampleBuffer, info); @@ -162,14 +162,16 @@ int32_t AVMuxerStub::Init(MessageParcel &data, MessageParcel &reply) // TODO: 补充LOG说明 (void)data; (void)reply; + bool ret = reply.WriteInt32(Init()); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } int32_t AVMuxerStub::DestroyStub(MessageParcel &data, MessageParcel &reply) { (void)data; - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(DestroyStub()), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(DestroyStub()); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } @@ -177,18 +179,16 @@ int32_t AVMuxerStub::SetLocation(MessageParcel &data, MessageParcel &reply) { float latitude = data.ReadFloat(); float longitude = data.ReadFloat(); - - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(SetLocation(latitude, longitude)), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(SetLocation(latitude, longitude)); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } int32_t AVMuxerStub::SetRotation(MessageParcel &data, MessageParcel &reply) { int32_t rotation = data.ReadInt32(); - - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(SetRotation(rotation)), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(SetRotation(rotation)); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } @@ -196,29 +196,26 @@ int32_t AVMuxerStub::SetParameter(MessageParcel &data, MessageParcel &reply) { Format format; AVCodecParcel::Unmarshalling(data, format); - - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(SetParameter(format)), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(SetParameter(format)); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } int32_t AVMuxerStub::AddTrack(MessageParcel &data, MessageParcel &reply) { Format generalFormat; + uint32_t trackIndex = data.ReadInt32(); (void)AVCodecParcel::Unmarshalling(data, generalFormat); - // TODO: - uint32_t trackIndex = 0; - - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(AddTrack(trackIndex, generalFormat)), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(AddTrack(trackIndex, generalFormat)); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } int32_t AVMuxerStub::Start(MessageParcel &data, MessageParcel &reply) { (void)data; - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(Start()), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(Start()); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } @@ -226,15 +223,22 @@ int32_t AVMuxerStub::WriteSampleBuffer(MessageParcel &data, MessageParcel &reply { (void)data; (void)reply; - + uint32_t trackIndex = data.ReadInt32(); + std::shared_ptr sampleBuffer = ReadAVSharedMemoryFromParcel(data); + AVCodecBufferInfo bufferInfo; + bufferInfo.presentationTimeUs = data.ReadInt64(); + bufferInfo.size = data.ReadInt32(); + bufferInfo.offset = data.ReadInt32(); + bool ret = reply.WriteInt32(WriteSampleBuffer(trackIndex, sampleBuffer, bufferInfo)); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } int32_t AVMuxerStub::Stop(MessageParcel &data, MessageParcel &reply) { (void)data; - // TODO: 补充LOG说明 - CHECK_AND_RETURN_RET_LOG(reply.WriteInt32(Stop()), AVCS_ERR_UNKNOWN, ""); + bool ret = reply.WriteInt32(Stop()); + CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_INVALID_OPERATION, "MessageParcel write failed"); return AVCS_ERR_OK; } diff --git a/services/services/muxer/ipc/include/avmuxer_proxy.h b/services/services/muxer/ipc/include/avmuxer_proxy.h index 7b500842a..12abdbfc7 100644 --- a/services/services/muxer/ipc/include/avmuxer_proxy.h +++ b/services/services/muxer/ipc/include/avmuxer_proxy.h @@ -31,7 +31,7 @@ public: int32_t SetParameter(const Format &generalFormat) override; int32_t AddTrack(uint32_t &trackIndex, const Format &trackFormat) override; int32_t Start() override; - int32_t WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) override; + int32_t WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) override; int32_t Stop() override; int32_t DestroyStub() override; diff --git a/services/services/muxer/ipc/include/avmuxer_stub.h b/services/services/muxer/ipc/include/avmuxer_stub.h index bec219219..f807a2ccf 100644 --- a/services/services/muxer/ipc/include/avmuxer_stub.h +++ b/services/services/muxer/ipc/include/avmuxer_stub.h @@ -36,7 +36,7 @@ public: int32_t SetParameter(const Format &generalFormat) override; int32_t AddTrack(uint32_t &trackIndex, const Format &trackFormat) override; int32_t Start() override; - int32_t WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) override; + int32_t WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) override; int32_t Stop() override; int32_t DumpInfo(int32_t fd); diff --git a/services/services/muxer/ipc/include/i_avmuxer_service.h b/services/services/muxer/ipc/include/i_avmuxer_service.h index 88f2b26e4..91da33755 100644 --- a/services/services/muxer/ipc/include/i_avmuxer_service.h +++ b/services/services/muxer/ipc/include/i_avmuxer_service.h @@ -32,7 +32,7 @@ public: virtual int32_t SetParameter(const Format &generalFormat) = 0; virtual int32_t AddTrack(uint32_t &trackIndex, const Format &trackFormat) = 0; virtual int32_t Start() = 0; - virtual int32_t WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) = 0; + virtual int32_t WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) = 0; virtual int32_t Stop() = 0; virtual int32_t DestroyStub() = 0; @@ -45,7 +45,6 @@ public: START, WRITE_SAMPLE_BUFFER, STOP, - DESTROY_STUB, }; diff --git a/services/services/muxer/server/avmuxer_server.cpp b/services/services/muxer/server/avmuxer_server.cpp index 1f6dbd1f9..9b0d02c6f 100644 --- a/services/services/muxer/server/avmuxer_server.cpp +++ b/services/services/muxer/server/avmuxer_server.cpp @@ -40,15 +40,11 @@ AVMuxerServer::AVMuxerServer() AVMuxerServer::~AVMuxerServer() { AVCODEC_LOGD("0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this)); - std::lock_guard lock(mutex_); - - // avmuxerEngine_ = nullptr; } int32_t AVMuxerServer::InitServer() { - return AVCS_ERR_OK; } @@ -67,7 +63,6 @@ int32_t AVMuxerServer::SetLocation(float latitude, float longitude) (void)longitude; std::lock_guard lock(mutex_); - return AVCS_ERR_OK; } @@ -106,7 +101,7 @@ int32_t AVMuxerServer::Start() return AVCS_ERR_OK; } -int32_t AVMuxerServer::WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) +int32_t AVMuxerServer::WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) { // TODO:achieve it (void)trackIndex; diff --git a/services/services/muxer/server/include/avmuxer_server.h b/services/services/muxer/server/include/avmuxer_server.h index d75c2db2a..1764ab79b 100644 --- a/services/services/muxer/server/include/avmuxer_server.h +++ b/services/services/muxer/server/include/avmuxer_server.h @@ -34,7 +34,7 @@ public: int32_t SetParameter(const Format &generalFormat) override; int32_t AddTrack(uint32_t &trackIndex, const Format &trackFormat) override; int32_t Start() override; - int32_t WriteSampleBuffer(uint32_t trackIndex, uint8_t *sampleBuffer, AVCodecBufferInfo info) override; + int32_t WriteSampleBuffer(uint32_t trackIndex, const std::shared_ptr &sampleBuffer, AVCodecBufferInfo info) override; int32_t Stop() override; private: diff --git a/services/services/sa_avcodec/client/avcodec_client.cpp b/services/services/sa_avcodec/client/avcodec_client.cpp index c15945846..a6d61eb57 100644 --- a/services/services/sa_avcodec/client/avcodec_client.cpp +++ b/services/services/sa_avcodec/client/avcodec_client.cpp @@ -175,13 +175,13 @@ std::shared_ptr AVCodecClient::CreateMuxerService() sptr object = avCodecProxy_->GetSubSystemAbility( IStandardAVCodecService::AVCodecSystemAbility::AVCODEC_MUXER, listenerStub_->AsObject()); - CHECK_AND_RETURN_RET_LOG(object != nullptr, nullptr, "muxer proxy object is nullptr."); + CHECK_AND_RETURN_RET_LOG(object != nullptr, nullptr, "Muxer proxy object is nullptr."); sptr muxerProxy = iface_cast(object); - CHECK_AND_RETURN_RET_LOG(muxerProxy != nullptr, nullptr, "muxer proxy is nullptr."); + CHECK_AND_RETURN_RET_LOG(muxerProxy != nullptr, nullptr, "Muxer proxy is nullptr."); std::shared_ptr muxerClient = AVMuxerClient::Create(muxerProxy); - CHECK_AND_RETURN_RET_LOG(muxerClient != nullptr, nullptr, "failed to create muxer client."); + CHECK_AND_RETURN_RET_LOG(muxerClient != nullptr, nullptr, "Failed to create muxer client."); muxerClientList_.push_back(muxerClient); return muxerClient; diff --git a/services/services/sa_avcodec/server/avcodec_server_manager.cpp b/services/services/sa_avcodec/server/avcodec_server_manager.cpp index 6db06b87b..0450ac464 100644 --- a/services/services/sa_avcodec/server/avcodec_server_manager.cpp +++ b/services/services/sa_avcodec/server/avcodec_server_manager.cpp @@ -287,7 +287,7 @@ sptr AVCodecServerManager::CreateMuxerStubObject() } sptr stub = AVMuxerStub::Create(); if (stub == nullptr) { - AVCODEC_LOGE("failed to create AVMuxerStub"); + AVCODEC_LOGE("Failed to create AVMuxerStub"); return nullptr; } sptr object = stub->AsObject(); @@ -305,7 +305,7 @@ sptr AVCodecServerManager::CreateMuxerStubObject() dumperTbl_[StubType::MUXER].emplace_back(dumper); AVCODEC_LOGD("The number of muxer services(%{public}zu).", muxerStubMap_.size()); if (Dump(-1, std::vector()) != OHOS::NO_ERROR) { - AVCODEC_LOGW("failed to call InstanceDump"); + AVCODEC_LOGW("Failed to call InstanceDump"); } } return object;