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 "avmuxer_sample.h" 17#include "nocopyable.h" 18using namespace std; 19 20namespace OHOS { 21namespace MediaAVCodec { 22AVMuxerSample::AVMuxerSample() 23{ 24} 25 26AVMuxerSample::~AVMuxerSample() 27{ 28} 29 30bool AVMuxerSample::CreateMuxer(int32_t fd, const OH_AVOutputFormat format) 31{ 32 muxer_ = AVMuxerMockFactory::CreateMuxer(fd, format); 33 return muxer_ != nullptr; 34} 35 36int32_t AVMuxerSample::Destroy() 37{ 38 if (muxer_ == nullptr) { 39 return AV_ERR_INVALID_VAL; 40 } 41 return muxer_->Destroy(); 42} 43 44int32_t AVMuxerSample::Start() 45{ 46 if (muxer_ == nullptr) { 47 return AV_ERR_INVALID_VAL; 48 } 49 return muxer_->Start(); 50} 51 52int32_t AVMuxerSample::Stop() 53{ 54 if (muxer_ == nullptr) { 55 return AV_ERR_INVALID_VAL; 56 } 57 return muxer_->Stop(); 58} 59 60int32_t AVMuxerSample::AddTrack(int32_t &trackIndex, std::shared_ptr<FormatMock> &trackFormat) 61{ 62 if (muxer_ == nullptr) { 63 return AV_ERR_INVALID_VAL; 64 } 65 return muxer_->AddTrack(trackIndex, trackFormat); 66} 67 68int32_t AVMuxerSample::WriteSample(uint32_t trackIndex, const uint8_t *sample, const OH_AVCodecBufferAttr &info) 69{ 70 if (muxer_ == nullptr) { 71 return AV_ERR_INVALID_VAL; 72 } 73 return muxer_->WriteSample(trackIndex, sample, info); 74} 75 76int32_t AVMuxerSample::WriteSampleBuffer(uint32_t trackIndex, const OH_AVBuffer *sample) 77{ 78 if (muxer_ == nullptr) { 79 return AV_ERR_INVALID_VAL; 80 } 81 return muxer_->WriteSampleBuffer(trackIndex, sample); 82} 83 84int32_t AVMuxerSample::SetTimedMetadata() 85{ 86 if (muxer_ == nullptr) { 87 return AV_ERR_INVALID_VAL; 88 } 89 return muxer_->SetTimedMetadata(); 90} 91 92int32_t AVMuxerSample::SetRotation(int32_t rotation) 93{ 94 if (muxer_ == nullptr) { 95 return AV_ERR_INVALID_VAL; 96 } 97 return muxer_->SetRotation(rotation); 98} 99} // namespace MediaAVCodec 100} // namespace OHOS 101