1 /* 2 * Copyright (C) 2021-2022 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 A2DP_CODEC_WRAPPER_H 17 #define A2DP_CODEC_WRAPPER_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <list> 22 23 #include "a2dp_codec_config.h" 24 #include "base_def.h" 25 #include "packet.h" 26 27 namespace OHOS { 28 namespace bluetooth { 29 // A2dp encoder interface 30 class A2dpEncoder { 31 public: A2dpEncoder(A2dpCodecConfig * config)32 explicit A2dpEncoder(A2dpCodecConfig *config) 33 : config_(config), transmitQueueLength_(0) 34 {} 35 virtual ~A2dpEncoder() = default; 36 virtual void ResetFeedingState(void) = 0; SetTransmitQueueLength(size_t length)37 virtual void SetTransmitQueueLength(size_t length) 38 { 39 transmitQueueLength_ = length; 40 } 41 virtual void SendFrames(uint64_t timeStampUs) = 0; 42 virtual void UpdateEncoderParam() = 0; 43 virtual void GetRenderPosition(uint64_t &sendDataSize, uint32_t &timeStamp) = 0; 44 45 protected: 46 BT_DISALLOW_COPY_AND_ASSIGN(A2dpEncoder); 47 A2dpCodecConfig *config_; 48 size_t transmitQueueLength_; 49 }; 50 51 // A2dpDecoderObserver is responsible of receiving decoded audio data from a2dp 52 // decoder 53 class A2dpDecoderObserver { 54 public: 55 virtual ~A2dpDecoderObserver() = default; 56 virtual void DataAvailable(uint8_t *buf, uint32_t size) = 0; 57 }; 58 59 // A2dp decoder interface 60 class A2dpDecoder { 61 public: A2dpDecoder(A2dpDecoderObserver * observer)62 A2dpDecoder(A2dpDecoderObserver *observer) : observer_(observer) 63 {} 64 virtual ~A2dpDecoder() = default; 65 virtual bool DecodePacket(uint8_t *data, uint16_t size) = 0; 66 67 protected: 68 BT_DISALLOW_COPY_AND_ASSIGN(A2dpDecoder); 69 A2dpDecoderObserver *observer_; 70 }; 71 } // namespace bluetooth 72 } // namespace OHOS 73 74 #endif // !A2DP_CODEC_WRAPPER_H 75