1 /* 2 * Copyright (c) 2021 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 OHOS_DCAMERA_CODEC_EVENT_H 17 #define OHOS_DCAMERA_CODEC_EVENT_H 18 19 #include <vector> 20 21 #include "event.h" 22 #include "data_buffer.h" 23 #include "image_common_type.h" 24 25 namespace OHOS { 26 namespace DistributedHardware { 27 enum class VideoCodecAction : int32_t { 28 NO_ACTION = 0, 29 ACTION_ONCE_AGAIN = 1, 30 }; 31 32 class CodecPacket { 33 public: CodecPacket()34 CodecPacket() : videoCodec_(VideoCodecType::NO_CODEC) {} CodecPacket(VideoCodecType videoCodec,const std::vector<std::shared_ptr<DataBuffer>> & multiDataBuffers)35 CodecPacket(VideoCodecType videoCodec, const std::vector<std::shared_ptr<DataBuffer>>& multiDataBuffers) 36 : videoCodec_(videoCodec), multiDataBuffers_(multiDataBuffers) {} 37 ~CodecPacket() = default; 38 SetVideoCodecType(VideoCodecType videoCodec)39 void SetVideoCodecType(VideoCodecType videoCodec) 40 { 41 videoCodec_ = videoCodec; 42 } 43 GetVideoCodecType()44 VideoCodecType GetVideoCodecType() const 45 { 46 return videoCodec_; 47 } 48 SetDataBuffers(std::vector<std::shared_ptr<DataBuffer>> & multiDataBuffers)49 void SetDataBuffers(std::vector<std::shared_ptr<DataBuffer>>& multiDataBuffers) 50 { 51 multiDataBuffers_ = multiDataBuffers; 52 } 53 GetDataBuffers()54 std::vector<std::shared_ptr<DataBuffer>> GetDataBuffers() const 55 { 56 return multiDataBuffers_; 57 } 58 59 private: 60 VideoCodecType videoCodec_; 61 std::vector<std::shared_ptr<DataBuffer>> multiDataBuffers_; 62 }; 63 64 class DCameraCodecEvent : public Event { TYPEINDENT(DCameraCodecEvent)65 TYPEINDENT(DCameraCodecEvent) 66 public: 67 DCameraCodecEvent(EventSender& sender, const std::shared_ptr<CodecPacket>& codecPacket) 68 : Event(sender), codecPacket_(codecPacket), action_(VideoCodecAction::NO_ACTION) {} DCameraCodecEvent(EventSender & sender,const std::shared_ptr<CodecPacket> & codecPacket,VideoCodecAction otherAction)69 DCameraCodecEvent(EventSender& sender, const std::shared_ptr<CodecPacket>& codecPacket, 70 VideoCodecAction otherAction) 71 : Event(sender), codecPacket_(codecPacket), action_(otherAction) {} ~DCameraCodecEvent()72 ~DCameraCodecEvent() {} 73 GetCodecPacket()74 std::shared_ptr<CodecPacket> GetCodecPacket() const 75 { 76 return codecPacket_; 77 } 78 GetAction()79 VideoCodecAction GetAction() const 80 { 81 return action_; 82 } 83 84 private: 85 std::shared_ptr<CodecPacket> codecPacket_; 86 VideoCodecAction action_; 87 }; 88 } // namespace DistributedHardware 89 } // namespace OHOS 90 #endif // OHOS_DCAMERA_CODEC_EVENT_H 91