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 #ifndef I_STREAM_H 17 #define I_STREAM_H 18 19 #include "audio_info.h" 20 #include "audio_stream_info.h" 21 22 namespace OHOS { 23 namespace AudioStandard { 24 enum IOperation { 25 OPERATION_INVALID = -1, 26 OPERATION_STARTED, 27 OPERATION_PAUSED, 28 OPERATION_STOPPED, 29 OPERATION_FLUSHED, 30 OPERATION_DRAINED, 31 OPERATION_RELEASED, 32 OPERATION_UNDERRUN, 33 OPERATION_UNDERFLOW, 34 OPERATION_SET_OFFLOAD_ENABLE, 35 OPERATION_UNSET_OFFLOAD_ENABLE, 36 OPERATION_DATA_LINK_CONNECTING, 37 OPERATION_DATA_LINK_CONNECTED, 38 }; 39 40 enum IStatus { 41 I_STATUS_INVALID = -1, 42 I_STATUS_IDLE, 43 I_STATUS_STARTING, 44 I_STATUS_STARTED, 45 I_STATUS_PAUSING, 46 I_STATUS_PAUSED, 47 I_STATUS_FLUSHING_WHEN_STARTED, 48 I_STATUS_FLUSHING_WHEN_PAUSED, 49 I_STATUS_FLUSHING_WHEN_STOPPED, 50 I_STATUS_DRAINING, 51 I_STATUS_DRAINED, 52 I_STATUS_STOPPING, 53 I_STATUS_STOPPED, 54 I_STATUS_RELEASING, 55 I_STATUS_RELEASED, 56 }; 57 58 class IStatusCallback { 59 public: 60 virtual void OnStatusUpdate(IOperation operation) = 0; 61 }; 62 63 class IStream { 64 public: 65 virtual void SetStreamIndex(uint32_t index) = 0; 66 virtual uint32_t GetStreamIndex() = 0; 67 virtual int32_t Start() = 0; 68 virtual int32_t Pause(bool isStandby = false) = 0; 69 virtual int32_t Flush() = 0; 70 virtual int32_t Drain() = 0; 71 virtual int32_t Stop() = 0; 72 virtual int32_t Release() = 0; 73 virtual void RegisterStatusCallback(const std::weak_ptr<IStatusCallback> &callback) = 0; 74 virtual BufferDesc DequeueBuffer(size_t length) = 0; 75 virtual int32_t EnqueueBuffer(const BufferDesc &bufferDesc) = 0; 76 }; 77 } // namespace AudioStandard 78 } // namespace OHOS 79 #endif // I_STREAM_H 80