From 6a8d4884e899039ce8de3bd4f0f209e62e3521cf Mon Sep 17 00:00:00 2001 From: FileStream Date: Sat, 20 Apr 2024 18:05:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=A4=96=E5=90=8C=E5=BD=95=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: FileStream --- .../inner_api/common/media_data_source.h | 27 +++++++++++++++++++ interface/inner_api/filter/filter.h | 1 + 2 files changed, 28 insertions(+) diff --git a/interface/inner_api/common/media_data_source.h b/interface/inner_api/common/media_data_source.h index 5d845b90..4c163fff 100644 --- a/interface/inner_api/common/media_data_source.h +++ b/interface/inner_api/common/media_data_source.h @@ -17,6 +17,7 @@ #define MEDIA_DATA_SOURCE_H_ #include "buffer/avsharedmemory.h" +#include "buffer/avbuffer.h" namespace OHOS { namespace Media { @@ -66,6 +67,32 @@ public: // This interface has been deprecated virtual int32_t ReadAt(uint32_t length, const std::shared_ptr &mem) = 0; }; + +class IAudioDataSource { +public: + virtual ~IAudioDataSource() = default; + + /** + * @brief Player use ReadAt to tell user the desired file position and length.(length is number of Bytes) + * Then usr filled the mem, and return the actual length of mem. + * @param mem The stream mem need to fill. see avsharedmemory.h. + * @param length The stream length player want to get. + * @param pos The stream pos player want get start. + * The length of the filled memory must match the actual length returned. + * @return The actual length of stream mem filled, if failed or no mem return MediaDataSourceError. + */ + virtual int32_t ReadAt(std::shared_ptr buffer, uint32_t length) = 0; + + /** + * @brief Get the total size of the stream. + * If the user does not know the length of the stream, size should be assigned -1, + * player will use the datasource not seekable. + * @param size Total size of the stream. If no size set -1. + * @return MSERR_OK if ok; others if failed. see media_errors.h + */ + virtual int32_t GetSize(int64_t& size) = 0; +}; + } // namespace Media } // namespace OHOS #endif // MEDIA_DATA_SOURCE_H_ \ No newline at end of file diff --git a/interface/inner_api/filter/filter.h b/interface/inner_api/filter/filter.h index e5263b6b..852a5c1f 100644 --- a/interface/inner_api/filter/filter.h +++ b/interface/inner_api/filter/filter.h @@ -43,6 +43,7 @@ enum class FilterType { FILTERTYPE_ASINK, FILTERTYPE_FSINK, AUDIO_CAPTURE, + AUDIO_DATA_SOURCE, VIDEO_CAPTURE, FILTERTYPE_MAX, }; -- Gitee