1 /* 2 * Copyright (c) 2024-2024 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 #ifndef AVCODEC_AUDIO_VIDEO_MUXER_H 17 #define AVCODEC_AUDIO_VIDEO_MUXER_H 18 19 #include "native_avmuxer.h" 20 #include "native_avcodec_base.h" 21 #include "native_avformat.h" 22 #include "native_avbuffer.h" 23 #include <atomic> 24 #include <cstdint> 25 #include <refbase.h> 26 #include "avmuxer.h" 27 #include "media_library/photo_asset_interface.h" 28 #include "media_description.h" 29 30 namespace OHOS { 31 namespace CameraStandard { 32 enum TrackType { 33 AUDIO_TRACK = 0, 34 VIDEO_TRACK, 35 META_TRACK 36 }; 37 using namespace MediaAVCodec; 38 class AudioVideoMuxer : public RefBase { 39 public: 40 explicit AudioVideoMuxer(); 41 ~AudioVideoMuxer(); 42 43 int32_t Create(OH_AVOutputFormat format, PhotoAssetIntf* photoAssetProxy); 44 int32_t AddTrack(int &trackId, std::shared_ptr<Format> format, TrackType type); 45 int32_t Start(); 46 int32_t WriteSampleBuffer(std::shared_ptr<OHOS::Media::AVBuffer> sample, TrackType type); 47 int32_t Stop(); 48 int32_t Release(); 49 int32_t SetRotation(int32_t rotation); 50 int32_t SetCoverTime(float timems); 51 int32_t SetTimedMetadata(); 52 int32_t GetVideoFd(); 53 PhotoAssetIntf* GetPhotoAssetProxy(); 54 std::atomic<int32_t> releaseSignal_ = 2; 55 56 private: 57 std::shared_ptr<AVMuxer> muxer_ = nullptr; 58 int32_t fd_ = -1; 59 PhotoAssetIntf* photoAssetProxy_ = nullptr; 60 int audioTrackId_ = -1; 61 int videoTrackId_ = -1; 62 int metaTrackId_ = -1; 63 }; 64 } // CameraStandard 65 } // OHOS 66 #endif