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 }; 37 38 enum IStatus { 39 I_STATUS_INVALID = -1, 40 I_STATUS_IDLE, 41 I_STATUS_STARTING, 42 I_STATUS_STARTED, 43 I_STATUS_PAUSING, 44 I_STATUS_PAUSED, 45 I_STATUS_FLUSHING_WHEN_STARTED, 46 I_STATUS_FLUSHING_WHEN_PAUSED, 47 I_STATUS_FLUSHING_WHEN_STOPPED, 48 I_STATUS_DRAINING, 49 I_STATUS_DRAINED, 50 I_STATUS_STOPPING, 51 I_STATUS_STOPPED, 52 I_STATUS_RELEASING, 53 I_STATUS_RELEASED, 54 }; 55 56 class IStatusCallback { 57 public: 58 virtual void OnStatusUpdate(IOperation operation) = 0; 59 }; 60 61 class IStream { 62 public: 63 virtual void SetStreamIndex(uint32_t index) = 0; 64 virtual uint32_t GetStreamIndex() = 0; 65 virtual int32_t Start() = 0; 66 virtual int32_t Pause() = 0; 67 virtual int32_t Flush() = 0; 68 virtual int32_t Drain() = 0; 69 virtual int32_t Stop() = 0; 70 virtual int32_t Release() = 0; 71 virtual void RegisterStatusCallback(const std::weak_ptr<IStatusCallback> &callback) = 0; 72 virtual BufferDesc DequeueBuffer(size_t length) = 0; 73 virtual int32_t EnqueueBuffer(const BufferDesc &bufferDesc) = 0; 74 }; 75 } // namespace AudioStandard 76 } // namespace OHOS 77 #endif // I_STREAM_H 78