已合并
add AVPlayer ndk/sdk interfaces and add AVMetedataExtractor ndk interfaces #4421
add AVPlayer ndk/sdk interfaces and add AVMetedataExtractor ndk interfaces #4421
已合并
wangqg创建于 2025年12月23日
17 个文件变更+1830-23
@@ -21,6 +21,8 @@
21 { "name": "OH_AVFormat_GetBuffer" },21 { "name": "OH_AVFormat_GetBuffer" },
22 { "name": "OH_AVFormat_DumpInfo" },22 { "name": "OH_AVFormat_DumpInfo" },
23 { "name": "OH_AVFormat_GetIntBuffer" },23 { "name": "OH_AVFormat_GetIntBuffer" },
24+ { "name": "OH_AVFormat_GetKeyCount" },
25+ { "name": "OH_AVFormat_GetKey" },
24 { "name": "OH_AVMemory_Create" },26 { "name": "OH_AVMemory_Create" },
25 { "name": "OH_AVMemory_GetAddr" },27 { "name": "OH_AVMemory_GetAddr" },
26 { "name": "OH_AVMemory_GetSize" },28 { "name": "OH_AVMemory_GetSize" },
@@ -180,6 +180,11 @@ typedef enum OH_AVErrCode {
180 * @since 14180 * @since 14
181 */181 */
182 AV_ERR_IO_UNSUPPORTED_REQUEST = 5411011,182 AV_ERR_IO_UNSUPPORTED_REQUEST = 5411011,
183+ /**
184+ * @error Http clear text not permitted.
185+ * @since 23
186+ */
187+ AV_ERR_IO_CLEARTEXT_NOT_PERMITTED = 5411012,
183 /**188 /**
184 * @error Signals a stream format change in synchronous mode.189 * @error Signals a stream format change in synchronous mode.
185 * Required follow-up actions:190 * Required follow-up actions:
@@ -196,6 +201,16 @@ typedef enum OH_AVErrCode {
196 * @since 20201 * @since 20
197 */202 */
198 AV_ERR_TRY_AGAIN_LATER = 5410006,203 AV_ERR_TRY_AGAIN_LATER = 5410006,
204+ /**
205+ * @error Super-resolution unsupported.
206+ * @since 23
207+ */
208+ AV_ERR_SUPER_RESOLUTION_UNSUPPORTED = 5410003,
209+ /**
210+ * @error No PlaybackStrategy set to enable super-resolution feature.
211+ * @since 23
212+ */
213+ AV_ERR_SUPER_RESOLUTION_NOT_ENABLED = 5410004,
199} OH_AVErrCode;214} OH_AVErrCode;
200 215 
201#ifdef __cplusplus216#ifdef __cplusplus
@@ -392,6 +392,32 @@ bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32
392 */392 */
393bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size);393bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size);
394 394 
395+/**
396+ * @brief Get the total number of keys contained in OH_AVFormat.
397+ * @param format Pointer to an OH_AVFormat instance
398+ * @return Returns the number of keys on success; returns 0 on failure
399+ * @details Possible failure causes:
400+ * 1. input format is NULL;
401+ * 2. system resources are insufficient.
402+ * @since 23
403+ */
404+uint32_t OH_AVFormat_GetKeyCount(OH_AVFormat *format);
405+ 
406+/**
407+ * @brief Get the key name string by index from OH_AVFormat.
408+ * @param format Pointer to an OH_AVFormat instance
409+ * @param index Zero-based index of the key to query, range: [0, OH_AVFormat_GetKeyCount(format))
410+ * @param key Output pointer to receive the key name string; the lifecycle is bound to the format
411+ * @return Returns TRUE on success, FALSE on failure
412+ * @details Possible failure causes:
413+ * 1. input format is NULL;
414+ * 2. index is out of range;
415+ * 3. key is NULL;
416+ * 4. system resources are insufficient.
417+ * @since 23
418+ */
419+bool OH_AVFormat_GetKey(OH_AVFormat *format, uint32_t index, const char **key);
420+ 
395#ifdef __cplusplus421#ifdef __cplusplus
396}422}
397#endif423#endif
@@ -0,0 +1,67 @@
1+/*
2+ * Copyright (C) 2025 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+/**
17+ * @addtogroup AVMediaBase
18+ * @{
19+ *
20+ * @brief Defines the structure and enumeration for AVMedia.
21+ *
22+ * @syscap SystemCapability.Multimedia.Media.Core
23+ * @since 23
24+ */
25+ 
26+/**
27+ * @file avmedia_base.h
28+ *
29+ * @brief Defines the structure and enumeration for AVMedia.
30+ *
31+ * @kit MediaKit
32+ * @library libavmedia_base.so
33+ * @syscap SystemCapability.Multimedia.Media.Core
34+ * @since 23
35+ */
36+ 
37+#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMEDIA_BASE_H
38+#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMEDIA_BASE_H
39+ 
40+#ifdef __cplusplus
41+extern "C" {
42+#endif
43+ 
44+/**
45+ * @brief Enumerates the seek mode by the given time and the key frame.
46+ *
47+ * @since 23
48+ */
49+ typedef enum OH_AVMedia_SeekMode {
50+ /** Seek to keyframe after the time point. */
51+ OH_AVMEDIA_SEEK_NEXT_SYNC = 0,
52+
53+ /** Seek to keyframe before the time point. */
54+ OH_AVMEDIA_SEEK_PREVIOUS_SYNC = 1,
55+
56+ /** Seek to closest keyframe near the time point. */
57+ OH_AVMEDIA_SEEK_CLOSEST_SYNC = 2,
58+
59+ /** Seek to the time point */
60+ OH_AVMEDIA_SEEK_CLOSEST = 3,
61+} OH_AVMedia_SeekMode;
62+ 
63+#ifdef __cplusplus
64+}
65+#endif
66+#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMEDIA_BASE_H
67+/** @} */
@@ -0,0 +1,35 @@
1+# Copyright (C) 2025 Huawei Device Co., Ltd.
2+# Licensed under the Apache License, Version 2.0 (the "License");
3+# you may not use this file except in compliance with the License.
4+# You may obtain a copy of the License at
5+#
6+# http://www.apache.org/licenses/LICENSE-2.0
7+#
8+# Unless required by applicable law or agreed to in writing, software
9+# distributed under the License is distributed on an "AS IS" BASIS,
10+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+# See the License for the specific language governing permissions and
12+# limitations under the License.
13+ 
14+import("//build/ohos.gni")
15+import("//build/ohos/ndk/ndk.gni")
16+import("//foundation/multimedia/player_framework/config.gni")
17+ 
18+ohos_ndk_headers("avmedia_base_header") {
19+ dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
20+ sources = [
21+ "../avmedia_base.h",
22+ "../avmetakeys.h",
23+ ]
24+}
25+ 
26+ohos_ndk_library("libavmedia_base") {
27+ ndk_description_file = "./libavmedia_base.ndk.json"
28+ output_name = "avmedia_base"
29+ output_extension = "so"
30+ system_capability = "SystemCapability.Multimedia.Media.Core"
31+ system_capability_headers = [
32+ "multimedia/player_framework/avmedia_base.h",
33+ "multimedia/player_framework/avmetakeys.h",
34+ ]
35+}
@@ -0,0 +1,74 @@
1+[
2+ {
3+ "first_introduced": "23",
4+ "name": "OH_AVMETA_KEY_TRACK_INDEX"
5+ },
6+ {
7+ "first_introduced": "23",
8+ "name": "OH_AVMETA_KEY_TRACK_TYPE"
9+ },
10+ {
11+ "first_introduced": "23",
12+ "name": "OH_AVMETA_KEY_MIME_TYPE"
13+ },
14+ {
15+ "first_introduced": "23",
16+ "name": "OH_AVMETA_KEY_DURATION"
17+ },
18+ {
19+ "first_introduced": "23",
20+ "name": "OH_AVMETA_KEY_BITRATE"
21+ },
22+ {
23+ "first_introduced": "23",
24+ "name": "OH_AVMETA_KEY_FRAME_RATE"
25+ },
26+ {
27+ "first_introduced": "23",
28+ "name": "OH_AVMETA_KEY_WIDTH"
29+ },
30+ {
31+ "first_introduced": "23",
32+ "name": "OH_AVMETA_KEY_HEIGHT"
33+ },
34+ {
35+ "first_introduced": "23",
36+ "name": "OH_AVMETA_KEY_CHANNEL_COUNT"
37+ },
38+ {
39+ "first_introduced": "23",
40+ "name": "OH_AVMETA_KEY_SAMPLE_RATE"
41+ },
42+ {
43+ "first_introduced": "23",
44+ "name": "OH_AVMETA_KEY_SAMPLE_DEPTH"
45+ },
46+ {
47+ "first_introduced": "23",
48+ "name": "OH_AVMETA_KEY_LANGUAGE"
49+ },
50+ {
51+ "first_introduced": "23",
52+ "name": "OH_AVMETA_KEY_TRACK_NAME"
53+ },
54+ {
55+ "first_introduced": "23",
56+ "name": "OH_AVMETA_KEY_HDR_TYPE"
57+ },
58+ {
59+ "first_introduced": "23",
60+ "name": "OH_AVMETA_KEY_ORIGINAL_WIDTH"
61+ },
62+ {
63+ "first_introduced": "23",
64+ "name": "OH_AVMETA_KEY_ORIGINAL_HEIGHT"
65+ },
66+ {
67+ "first_introduced": "23",
68+ "name": "OH_AVMETA_KEY_REF_TRACK_IDS"
69+ },
70+ {
71+ "first_introduced": "23",
72+ "name": "OH_AVMETA_KEY_TRACK_REF_TYPE"
73+ }
74+]
@@ -0,0 +1,379 @@
1+/*
2+ * Copyright (C) 2025 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+/**
17+ * @addtogroup avmedia_source
18+ * @{
19+ *
20+ * @brief Defines APIs for AVMediaSource.
21+ *
22+ * @syscap SystemCapability.Multimedia.Media.Core
23+ * @since 23
24+ */
25+ 
26+/**
27+ * @file avmedia_source.h
28+ *
29+ * @brief Defines the structure and enumeration for AVMediaSource.
30+ *
31+ * @syscap SystemCapability.Multimedia.Media.Core
32+ * @kit MediaKit
33+ * @library libavmedia_source.so
34+ * @since 23
35+ */
36+ 
37+#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMEDIA_SOURCE_H
38+#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMEDIA_SOURCE_H
39+ 
40+#include <stdint.h>
41+#include <stdio.h>
42+#include "native_averrors.h"
43+#include "native_avcodec_base.h"
44+ 
45+#ifdef __cplusplus
46+extern "C" {
47+#endif
48+ 
49+/**
50+ * @brief Declares the http header type.
51+ * @since 23
52+ */
53+typedef struct OH_AVHttpHeader OH_AVHttpHeader;
54+ 
55+/**
56+ * @brief Declares media source type.
57+ * @since 23
58+ */
59+typedef struct OH_AVMediaSource OH_AVMediaSource;
60+ 
61+/**
62+ * @brief Loading Request object. Application obtains the requested resource location through this object
63+ * @since 23
64+ */
65+typedef struct OH_AVMediaSourceLoadingRequest OH_AVMediaSourceLoadingRequest;
66+ 
67+/**
68+ * @brief Declares media data loader type, which is implemented by applications.
69+ * @since 23
70+ */
71+typedef struct OH_AVMediaSourceLoader OH_AVMediaSourceLoader;
72+ 
73+/**
74+ * @brief The enum of the error code of network loading request.
75+ * @since 23
76+ */
77+typedef enum AVLoadingRequestError {
78+ /** Resouce is loaded successfully */
79+ AV_LOADING_ERROR_SUCCESS = 0,
80+ 
81+ /** Resource is not ready for access */
82+ AV_LOADING_ERROR_NOT_READY = 1,
83+ 
84+ /** Resource url does not exist */
85+ AV_LOADING_ERROR_NO_RESOURCE = 2,
86+ 
87+ /** The uuid of resource handle is valid */
88+ AV_LOADING_ERROR_INVALID_HANDLE = 3,
89+ 
90+ /** The client has no right to request the resource */
91+ AV_LOADING_ERROR_ACCESS_DENIED = 4,
92+ 
93+ /** Access time out */
94+ AV_LOADING_ERROR_ACCESS_TIMEOUT = 5,
95+ 
96+ /** Authorization failed */
97+ AV_LOADING_ERROR_AUTHORIZE_FAILED = 6,
98+} AVLoadingRequestError;
99+ 
100+/**
101+ * @brief Create an http header instance
102+ * @return Returns a pointer to an OH_AVHttpHeader instance for success, nullptr for failure
103+ * @since 23
104+ */
105+OH_AVHttpHeader *OH_AVHttpHeader_Create(void);
106+ 
107+/**
108+ * @brief Releases an http header instance
109+ * @param header Pointer to an OH_AVHttpHeader instance
110+ * @return Function result code.
111+ * (@link AV_ERR_OK) if the execution is successful.
112+ * (@link AV_ERR_INVALID_VAL) if input header is nullptr or player release failed.
113+ * @since 23
114+ */
115+OH_AVErrCode OH_AVHttpHeader_Destroy(OH_AVHttpHeader *header);
116+ 
117+/**
118+ * @brief Get the record count in the http header instance
119+ * @param header Pointer to an OH_AVHttpHeader instance
120+ * @param count The output record item count in the header instance
121+ * @return Function result code.
122+ * (@link AV_ERR_OK) if the execution is successful.
123+ * (@link AV_ERR_INVALID_VAL) if input header is nullptr.
124+ * @since 23
125+ */
126+OH_AVErrCode OH_AVHttpHeader_GetCount(OH_AVHttpHeader *header, uint32_t *count);
127+ 
128+/**
129+ * @brief add a key-value pair record to the http header instance
130+ * @param header Pointer to an OH_AVHttpHeader instance
131+ * @param key The key name of the record
132+ * @param value The value of the record
133+ * @return Function result code.
134+ * (@link AV_ERR_OK) if the execution is successful.
135+ * (@link AV_ERR_INVALID_VAL) if one of the parameters is nullptr.
136+ * @since 23
137+ */
138+OH_AVErrCode OH_AVHttpHeader_AddRecord(OH_AVHttpHeader *header, const char *key, const char *value);
139+ 
140+/**
141+ * @brief get the key-value pair record of the http header instance by the index
142+ * @param header Pointer to an OH_AVHttpHeader instance
143+ * @param index the position of the record in the header
144+ * @param key The output key name of the record
145+ * @param value The output value of the record
146+ * @return Function result code.
147+ * (@link AV_ERR_OK) if the execution is successful.
148+ * (@link AV_ERR_INVALID_VAL) if header is nullptr or index out of bound.
149+ * @since 23
150+ */
151+OH_AVErrCode OH_AVHttpHeader_GetRecord(OH_AVHttpHeader *header, uint32_t index, const char **key, const char **value);
152+ 
153+/**
154+ * @brief Creates a media source from url.
155+ * @param url Url of the media source. The following streaming media formats are supported: HLS,
156+ * HTTP-FLV, DASH, and HTTPS.
157+ * @param header Http headers attached to network request.
158+ * @return Returns a pointer to an OH_AVMediaSource instance for success, nullptr for failure
159+ * @since 23
160+ */
161+OH_AVMediaSource *OH_AVMediaSource_CreateWithUrl(const char *url, OH_AVHttpHeader *header);
162+ 
163+/**
164+ * @brief Creates a media source from OH_AVDataSource.
165+ * @param dataSource Pointer to a OH_AVDataSource
166+ * @return Returns a pointer to an OH_AVMediaSource instance for success, nullptr for failure
167+ * @since 23
168+ */
169+OH_AVMediaSource *OH_AVMediaSource_CreateWithDataSource(OH_AVDataSource *dataSource);
170+ 
171+/**
172+ * @brief Creates a media source from the FileDescriptor.
173+ * @param fd The fileDescriptor of data source.
174+ * @param offset The offset into the file to start reading.
175+ * @param size The file size in bytes.
176+ * @return Returns a pointer to an OH_AVMediaSource instance for success, nullptr for failure
177+ * @details Possible failure causes:
178+ * 1. fd is invalid.
179+ * 2. offset is invalid.
180+ * 3. size error.
181+ * 4. resource is invalid.
182+ * 5. file format is not supported.
183+ * @since 23
184+ */
185+OH_AVMediaSource *OH_AVMediaSource_CreateWithFd(int32_t fd, int64_t offset, int64_t size);
186+ 
187+/**
188+ * @brief Set media mime type to handle extended media source.
189+ * @param source Pointer to a OH_AVMediaSource.
190+ 
191+ * @param mimetype Source's mime type. (@link AV_MimeTypes).
192+ * @return Function result code.
193+ * (@link AV_ERR_OK) if the execution is successful.
194+ * (@link AV_ERR_INVALID_VAL) if source or mimetype is nullptr.
195+ * (@link AV_ERR_UNSUPPORTED_FORMAT) if mimetype is not supported.
196+ * @since 23
197+ */
198+OH_AVErrCode OH_AVMediaSource_SetMimeType(OH_AVMediaSource *source, const char *mimetype);
199+ 
200+/**
201+ * @brief Get the request url.
202+ * @param request the OH_AVMediaSourceLoadingRequest instance.
203+ * @param url the output url string.
204+ * @return Function result code.
205+ * (@link AV_ERR_OK) if the execution is successful.
206+ * (@link AV_ERR_INVALID_VAL) if request is nullptr or there is no url.
207+ * @since 23
208+ */
209+OH_AVErrCode OH_AVMediaSourceLoadingRequest_GetUrl(OH_AVMediaSourceLoadingRequest *request, const char **url);
210+ 
211+/**
212+ * @brief Get the request http header.
213+ * @param request the OH_AVMediaSourceLoadingRequest instance.
214+ * @param header the http header need to use in the http request.
215+ * @return Function result code.
216+ * (@link AV_ERR_OK) if the execution is successful.
217+ * (@link AV_ERR_INVALID_VAL) if request is nullptr.
218+ * @since 23
219+ */
220+OH_AVErrCode OH_AVMediaSourceLoadingRequest_GetHttpHeader(OH_AVMediaSourceLoadingRequest *request,
221+ OH_AVHttpHeader **header);
222+ 
223+/**
224+ * @brief The interface for application used to send requested data to AVPlayer.
225+ * @param request Parameters for the resource open request.
226+ * @param uuid ID for the resource handle.
227+ * @param offset Offset of the current media data relative to the start of the resource.
228+ * @param data Media data sent to the player.
229+ * @param dataSize - data length sent to player.
230+ * @return Accepted bytes for current read. The value less than zero means failed.
231+ * -2, Means player needs current data any more, the client should stop current read process.
232+ * -3, means player buffer is full, the client should wait for next read.
233+ * @since 23
234+ */
235+int32_t OH_AVMediaSourceLoadingRequest_RespondData(
236+ OH_AVMediaSourceLoadingRequest *request, int64_t uuid, int64_t offset, const uint8_t *data, uint64_t dataSize);
237+ 
238+/**
239+ * @brief The interface for application used to send respond header to AVPlayer
240+ * should be called before calling the (@link OH_AVMediaSourceLoadingRequest_RespondData()) for the first time.
241+ * @param request Parameters for the resource open request.
242+ * @param uuid ID for the resource handle.
243+ * @param header Header info in the http response.
244+ * The application can intersect the header fields with the fields supported by the underlying layer for
245+ * parsing or directly pass in all corresponding header information.
246+ * @param redirectUrl Redirect url from the http response if exist.
247+ * @since 23
248+ */
249+void OH_AVMediaSourceLoadingRequest_RespondHeader(
250+ OH_AVMediaSourceLoadingRequest *request, int64_t uuid, OH_AVHttpHeader *header, const char *redirectUrl);
251+ 
252+/**
253+ * @brief Notifies the player of the current request status. After pushing all the data for a single resource, the
254+ * application should send the *LOADING_ERROR_SUCCESS* state to notify the player that the resource push is
255+ * complete.
256+ * @param request Parameters for the resource open request.
257+ * @param uuid ID for the resource handle.
258+ * @param error Error state.
259+ * @since 23
260+ */
261+void OH_AVMediaSourceLoadingRequest_FinishLoading(
262+ OH_AVMediaSourceLoadingRequest *request, int64_t uuid, AVLoadingRequestError error);
263+ 
264+/**
265+ * @brief Create a OH_AVMediaSourceLoader instance.
266+ * @return OH_AVMediaSourceLoader pointer if success, else return NULL.
267+ * @since 23
268+ */
269+OH_AVMediaSourceLoader *OH_AVMediaSourceLoader_Create(void);
270+ 
271+/**
272+ * @brief Releases the OH_AVMediaSourceLoader instance.
273+ * @param loader The OH_AVMediaSourceLoader instance which to be released.
274+ * @return Function result code.
275+ * (@link AV_ERR_OK) if the execution is successful.
276+ * (@link AV_ERR_INVALID_VAL) if loader is nullptr or release failed.
277+ * @since 23
278+ */
279+OH_AVErrCode OH_AVMediaSourceLoader_Destroy(OH_AVMediaSourceLoader *loader);
280+ 
281+/**
282+ * @brief Set a source loader to a media source instance.
283+ * @param source the OH_AVMediaSource which need network delegation.
284+ * @param loader The OH_AVMediaSourceLoader instance
285+ * @return Function result code.
286+ * (@link AV_ERR_OK) if the execution is successful.
287+ * (@link AV_ERR_INVALID_VAL) if sourcer or loader is nullptr or release failed.
288+ * @since 23
289+ */
290+OH_AVErrCode OH_AVMediaSource_SetMediaSourceLoader(OH_AVMediaSource *source, OH_AVMediaSourceLoader *loader);
291+ 
292+/**
293+ * @brief Defines the SourceOpenCallback function which is called by the service.
294+ * client should process the incoming request
295+ * and return the unique handle to the open resource.
296+ * The client must return the handle immediately after processing the request.
297+ * @param request Parameters for the resource open request,
298+ * including detailed information about the requested resource and the data push method.
299+ * @param userData The data set by user in OH_AVMediaSourceLoader_SetSourceOpenCallback
300+ * @return The handler of current resource open request, the handler for the request object is unique.
301+ * A value greater than 0 means the request is successful.
302+ * A value less than or equal to 0 means it fails.
303+ * @since 23
304+ */
305+typedef int64_t (*OH_AVMediaSourceLoaderOnSourceOpenedCallback)(OH_AVMediaSourceLoadingRequest *request,
306+ void *userData);
307+ 
308+/**
309+ * @brief Defines the SourceReadCallback function which is called by the service. Client should record the read requests
310+ * and push the data through the (@link OH_AVMediaSourceLoadingRequest_RespondData) and
311+ * (@link OH_AVMediaSourceLoadingRequest_RespondHeader)
312+ * method of the request object when there is sufficient data.
313+ * The client must return the handle immediately after processing the request.
314+ * @param uuid ID for the resource handle.
315+ * @param requestedOffset Offset of the current media data relative to the start of the resource.
316+ * @param requestedLength length of the current request.
317+ * -1 means reaching the end of the resource, need to inform the player of the end of
318+ * the push through the (@link #finishLoading) method.
319+ * @param userData The data set by user in OH_AVMediaSourceLoader_SetSourceReadCallback
320+ * @since 23
321+ */
322+typedef void (*OH_AVMediaSourceLoaderOnSourceReadCallback)(int64_t uuid, int64_t requestedOffset,
323+ int64_t requestedLength, void *userData);
324+ 
325+/**
326+ * @brief Defines the SourceCloseCallback function which is called by the service.
327+ * Client should release related resources.
328+ * The client must return the handle immediately after processing the request.
329+ * @param uuid ID for the resource handle.
330+ * @param userData The data set by user in OH_AVMediaSourceLoader_SetSourceCloseCallback
331+ * @since 23
332+ */
333+typedef void (*OH_AVMediaSourceLoaderOnSourceClosedCallback)(int64_t uuid, void *userData);
334+ 
335+/**
336+ * @brief Set open callback function to the OH_AVMediaSourceLoader
337+ * @param loader The OH_AVMediaSourceLoader callback function interface set.
338+ * @param callback The open callback function to set.
339+ * @param userData The user defined data used in callback function.
340+ * @return Function result code.
341+ * (@link AV_ERR_OK) if the execution is successful.
342+ * (@link AV_ERR_INVALID_VAL) if loader is nullptr or release failed.
343+ * @since 23
344+ */
345+OH_AVErrCode OH_AVMediaSourceLoader_SetSourceOpenCallback(OH_AVMediaSourceLoader *loader,
346+ OH_AVMediaSourceLoaderOnSourceOpenedCallback callback, void *userData);
347+ 
348+/**
349+ * @brief Set read callback function to the OH_AVMediaSourceLoader
350+ * @param loader The OH_AVMediaSourceLoader callback function interface set.
351+ * @param callback The read callback function to set.
352+ * @param userData The user defined data used in callback function.
353+ * @return Function result code.
354+ * (@link AV_ERR_OK) if the execution is successful.
355+ * (@link AV_ERR_INVALID_VAL) if loader is nullptr or release failed.
356+ * @since 23
357+ */
358+OH_AVErrCode OH_AVMediaSourceLoader_SetSourceReadCallback(OH_AVMediaSourceLoader *loader,
359+ OH_AVMediaSourceLoaderOnSourceReadCallback callback, void *userData);
360+ 
361+/**
362+ * @brief Set close callback function to the OH_AVMediaSourceLoader
363+ * @param loader The OH_AVMediaSourceLoader callback function interface set.
364+ * @param callback The close callback function to set.
365+ * @param userData The user defined data used in callback function.
366+ * @return Function result code.
367+ * (@link AV_ERR_OK) if the execution is successful.
368+ * (@link AV_ERR_INVALID_VAL) if loader is nullptr or release failed.
369+ * @since 23
370+ */
371+OH_AVErrCode OH_AVMediaSourceLoader_SetSourceCloseCallback(OH_AVMediaSourceLoader *loader,
372+ OH_AVMediaSourceLoaderOnSourceClosedCallback callback, void *userData);
373+ 
374+#ifdef __cplusplus
375+}
376+#endif
377+ 
378+#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMEDIA_SOURCE_H
379+/** @} */
@@ -0,0 +1,29 @@
1+# Copyright (C) 2025 Huawei Device Co., Ltd.
2+# Licensed under the Apache License, Version 2.0 (the "License");
3+# you may not use this file except in compliance with the License.
4+# You may obtain a copy of the License at
5+#
6+# http://www.apache.org/licenses/LICENSE-2.0
7+#
8+# Unless required by applicable law or agreed to in writing, software
9+# distributed under the License is distributed on an "AS IS" BASIS,
10+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+# See the License for the specific language governing permissions and
12+# limitations under the License.
13+ 
14+import("//build/ohos.gni")
15+import("//build/ohos/ndk/ndk.gni")
16+import("//foundation/multimedia/player_framework/config.gni")
17+ 
18+ohos_ndk_headers("avmedia_source_header") {
19+ dest_dir = "$ndk_headers_out_dir/multimedia/player_framework"
20+ sources = [ "../avmedia_source.h" ]
21+}
22+ 
23+ohos_ndk_library("libavmedia_source") {
24+ ndk_description_file = "./libavmedia_source.ndk.json"
25+ output_name = "avmedia_source"
26+ output_extension = "so"
27+ system_capability = "SystemCapability.Multimedia.Media.Core"
28+ system_capability_headers = [ "multimedia/player_framework/avmedia_source.h" ]
29+}
@@ -0,0 +1,82 @@
1+[
2+ {
3+ "first_introduced": "23",
4+ "name": "OH_AVHttpHeader_Create"
5+ },
6+ {
7+ "first_introduced": "23",
8+ "name": "OH_AVHttpHeader_Destroy"
9+ },
10+ {
11+ "first_introduced": "23",
12+ "name": "OH_AVHttpHeader_GetCount"
13+ },
14+ {
15+ "first_introduced": "23",
16+ "name": "OH_AVHttpHeader_AddRecord"
17+ },
18+ {
19+ "first_introduced": "23",
20+ "name": "OH_AVHttpHeader_GetRecord"
21+ },
22+ {
23+ "first_introduced": "23",
24+ "name": "OH_AVMediaSource_CreateWithUrl"
25+ },
26+ {
27+ "first_introduced": "23",
28+ "name": "OH_AVMediaSource_CreateWithDataSource"
29+ },
30+ {
31+ "first_introduced": "23",
32+ "name": "OH_AVMediaSource_CreateWithFd"
33+ },
34+ {
35+ "first_introduced": "23",
36+ "name": "OH_AVMediaSource_SetMimeType"
37+ },
38+ {
39+ "first_introduced": "23",
40+ "name": "OH_AVMediaSourceLoadingRequest_GetUrl"
41+ },
42+ {
43+ "first_introduced": "23",
44+ "name": "OH_AVMediaSourceLoadingRequest_GetHttpHeader"
45+ },
46+ {
47+ "first_introduced": "23",
48+ "name": "OH_AVMediaSourceLoadingRequest_RespondData"
49+ },
50+ {
51+ "first_introduced": "23",
52+ "name": "OH_AVMediaSourceLoadingRequest_RespondHeader"
53+ },
54+ {
55+ "first_introduced": "23",
56+ "name": "OH_AVMediaSourceLoadingRequest_FinishLoading"
57+ },
58+ {
59+ "first_introduced": "23",
60+ "name": "OH_AVMediaSourceLoader_Create"
61+ },
62+ {
63+ "first_introduced": "23",
64+ "name": "OH_AVMediaSourceLoader_Destroy"
65+ },
66+ {
67+ "first_introduced": "23",
68+ "name": "OH_AVMediaSource_SetMediaSourceLoader"
69+ },
70+ {
71+ "first_introduced": "23",
72+ "name": "OH_AVMediaSourceLoader_SetSourceOpenCallback"
73+ },
74+ {
75+ "first_introduced": "23",
76+ "name": "OH_AVMediaSourceLoader_SetSourceReadCallback"
77+ },
78+ {
79+ "first_introduced": "23",
80+ "name": "OH_AVMediaSourceLoader_SetSourceCloseCallback"
81+ }
82+]
@@ -46,6 +46,8 @@
46#include "native_avcodec_base.h"46#include "native_avcodec_base.h"
47#include "native_avformat.h"47#include "native_avformat.h"
48#include "multimedia/image_framework/image/pixelmap_native.h"48#include "multimedia/image_framework/image/pixelmap_native.h"
49+#include "avmedia_source.h"
50+#include "avmedia_base.h"
49 51 
50#ifdef __cplusplus52#ifdef __cplusplus
51extern "C" {53extern "C" {
@@ -59,6 +61,140 @@ extern "C" {
59 */61 */
60typedef struct OH_AVMetadataExtractor OH_AVMetadataExtractor;62typedef struct OH_AVMetadataExtractor OH_AVMetadataExtractor;
61 63 
64+/**
65+ * @brief Create an OH_AVMetadataExtractor_OutputParam instance
66+ *
67+ * @return The new OH_AVMetadataExtractor_OutputParam instance.
68+ * @since 23
69+ */
70+OH_AVMetadataExtractor_OutputParam* OH_AVMetadataExtractor_OutputParam_Create();
71+ 
72+/**
73+ * @brief Release an OH_AVMetadataExtractor_OutputParam instance
74+ *
75+ * @param outputParam - Pointer to an OH_AVMetadataExtractor_OutputParam instance.
76+ * @since 23
77+ */
78+void OH_AVMetadataExtractor_OutputParam_Destroy(OH_AVMetadataExtractor_OutputParam* outputParam);
79+ 
80+/**
81+ * @brief Set an OH_AVMetadataExtractor_OutputParam instance's size attribute
82+ * If the width or height is negtive, use the original video width or height;
83+ * If the width or height is zero, keep the aspect ratio and scale image.
84+ * If width and height both are positive, scale image with input width and height parameter.
85+ * @param outputParam - Pointer to an OH_AVMetadataExtractor_OutputParam instance.
86+ * @param width - The width of output image, scaled if neccessary.
87+ * @param height - The height of output image, scaled if neccessary.
88+ * @return The return value is TRUE for success, FALSE for failure.
89+ * Possible failure causes: outputParam is nullptr.
90+ * @since 23
91+ */
92+bool OH_AVMetadataExtractor_OutputParam_SetSize(OH_AVMetadataExtractor_OutputParam* outputParam,
93+ int32_t width, int32_t height);
94+ 
95+/**
96+ * @brief Fetch an image at the specific time from a video resource.
97+ * This function must be called after source set.
98+ *
99+ * @param extractor - Pointer to an OH_AVMetadataExtractor instance.
100+ * @param timeUs - The time expected to fetch picture from the video resource. The unit is microsecond(us).
101+ * @param seekMode - The seek option about the relationship between the given timeUs and a key frame,
102+ * see {@link OH_AVMedia_SeekMode}.
103+ * @param outputParam - The output format of the image, e.g. height or width of the image.
104+ * see {@link OH_AVMetadataExtractor_OutputParam}.
105+ * If nullptr, the fetched frame uses video original size
106+ * @param pixelMap The fetched output image from the video source. For details, see {@link OH_PixelmapNative}.
107+ * @return Function result code.
108+ * {@link AV_ERR_OK} if the execution is successful.
109+ * {@link AV_ERR_INVALID_VAL} if the input param is invalid.
110+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed.
111+ * {@link AV_ERR_UNSUPPORTED_FORMAT} if format is unsupported.
112+ * {@link AV_ERR_SERVICE_DIED} if the service died.
113+ * {@link AV_ERR_IO_CLEARTEXT_NOT_PERMITTED} if http cleartext traffic is not permitted.
114+ * @since 23
115+ */
116+OH_AVErrCode OH_AVMetadataExtractor_FetchFrameByTime(OH_AVMetadataExtractor *extractor, int64_t timeUs,
117+ OH_AVMedia_SeekMode seekMode, const OH_AVMetadataExtractor_OutputParam* outputParam,
118+ OH_PixelmapNative** pixelMap);
119+ 
120+/**
121+ * @brief defines the callback function for frames fetched by AVMetadataExtractor
122+ *
123+ * @since 23
124+ */
125+typedef void (*OH_AVMetadataExtractor_OnFrameFetched)(OH_AVMetadataExtractor *extractor,
126+ const OH_AVMetadataExtractor_FrameInfo* frameInfo, OH_AVErrCode code, void *userData);
127+ 
128+/**
129+ * @brief Batch fetch images at the specific times from a video resource.
130+ * This function must be called after source set.
131+ *
132+ * @param extractor - Pointer to an OH_AVMetadataExtractor instance.
133+ * @param timesUs - The times array expected to fetch picture from the video resource. The unit is microsecond(us).
134+ * @param timesUsSize - The length of input times array.
135+ * @param seekMode - The seek option about the relationship between the given timeUs and a key frame,
136+ * see {@link OH_AVMedia_SeekMode}.
137+ * @param outputParam - The output format of the image, e.g. height or width of the image.
138+ * see {@link OH_AVMetadataExtractor_OutputParam}.
139+ * If nullptr, the fetched frame uses video original size
140+ * @param onFrameInfoCallback - The callback function when a frame is fetched or failed to fetch.
141+ * @param userData - The user custom data for callback function.
142+ * @return Function result code.
143+ * {@link AV_ERR_OK} if the execution is successful.
144+ * {@link AV_ERR_INVALID_VAL} if the input param is invalid.
145+ * {@link AV_ERR_SERVICE_DIED} if the service died.
146+ * {@link AV_ERR_IO_CLEARTEXT_NOT_PERMITTED} if http cleartext traffic is not permitted.
147+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed. Returned by onFrameInfoCallback.
148+ * {@link AV_ERR_UNSUPPORTED_FORMAT} if format is unsupported. Returned by onFrameInfoCallback.
149+ * {@link AV_ERR_TIMEOUT} if the execution is times out. Returned by onFrameInfoCallback.
150+ * @since 23
151+ */
152+OH_AVErrCode OH_AVMetadataExtractor_FetchFramesByTimes(OH_AVMetadataExtractor *extractor, int64_t timesUs[],
153+ uint16_t timesUsSize, OH_AVMedia_SeekMode seekMode, const OH_AVMetadataExtractor_OutputParam* outputParam,
154+ OH_AVMetadataExtractor_OnFrameFetched onFrameInfoCallback, void* userData);
155+ 
156+/**
157+ * @brief Cancel the batch fetch images operation (initiated by {@link OH_AVMetadataExtractor_FetchFramesByTimes}).
158+ * The pending fetches are cancelled and marked with CANCELLED result
159+ * in {@OH_AVMetadataExtractor_OnFrameFetched} callback
160+ *
161+ * @param extractor - Pointer to an OH_AVMetadataExtractor instance.
162+ * @since 23
163+ */
164+void OH_AVMetadataExtractor_CancelAllFetchFrames(OH_AVMetadataExtractor *extractor);
165+ 
166+/**
167+ * @brief Get the track description information from the media source.
168+ * This function must be called after source set.
169+ * @param extractor Pointer to an OH_AVMetadataExtractor instance.
170+ * @param index The index of the track description to retrieve.
171+ * @return Returns a pointer to an OH_AVFormat instance containing track description for success, nullptr for failure.
172+ * Possible failure causes: extractor is nullptr, no source set, or format is unsupported.
173+ * @since 23
174+ */
175+OH_AVFormat *OH_AVMetadataExtractor_GetTrackDescription(OH_AVMetadataExtractor *extractor, uint32_t index);
176+ 
177+/**
178+ * @brief Get the custom information from the media source.
179+ * This function must be called after source set.
180+ * @param extractor Pointer to an OH_AVMetadataExtractor instance.
181+ * @return Returns a pointer to an OH_AVFormat instance containing custom metadata for success, nullptr for failure.
182+ * Possible failure causes: extractor is nullptr, no source set, or custom info not found.
183+ * @since 23
184+ */
185+OH_AVFormat *OH_AVMetadataExtractor_GetCustomInfo(OH_AVMetadataExtractor *extractor);
186+ 
187+/**
188+ * @brief Set media source to the extractor
189+ * @param extractor Pointer to an OH_AVMetadataExtractor instance.
190+ * @param source The media source to set to the extractor.
191+ * @return Function result code.
192+ * {@link AV_ERR_OK} if the execution is successful.
193+ * {@link AV_ERR_INVALID_VAL} if input extractor is nullptr or input source is invalid.
194+ * @since 23
195+ */
196+OH_AVErrCode OH_AVMetadataExtractor_SetMediaSource(OH_AVMetadataExtractor *extractor, OH_AVMediaSource *source);
197+ 
62/**198/**
63 * @brief Create a metadata extractor.199 * @brief Create a metadata extractor.
64 *200 *
@@ -1,22 +1,58 @@
1-[1+[
2- {2+ {
3- "first_introduced": "18",3+ "first_introduced": "18",
4- "name": "OH_AVMetadataExtractor_Create"4+ "name": "OH_AVMetadataExtractor_Create"
5- },5+ },
6- {6+ {
7- "first_introduced": "18",7+ "first_introduced": "18",
8- "name": "OH_AVMetadataExtractor_SetFDSource"8+ "name": "OH_AVMetadataExtractor_SetFDSource"
9- },9+ },
10- {10+ {
11- "first_introduced": "18",11+ "first_introduced": "18",
12- "name": "OH_AVMetadataExtractor_FetchMetadata"12+ "name": "OH_AVMetadataExtractor_FetchMetadata"
13- },13+ },
14- {14+ {
15- "first_introduced": "18",15+ "first_introduced": "18",
16- "name": "OH_AVMetadataExtractor_FetchAlbumCover"16+ "name": "OH_AVMetadataExtractor_FetchAlbumCover"
17- },17+ },
18- {18+ {
19- "first_introduced": "18",19+ "first_introduced": "18",
20- "name": "OH_AVMetadataExtractor_Release"20+ "name": "OH_AVMetadataExtractor_Release"
21- }21+ },
22-]22+ {
23+ "first_introduced": "23",
24+ "name": "OH_AVMetadataExtractor_OutputParam_Create"
25+ },
26+ {
27+ "first_introduced": "23",
28+ "name": "OH_AVMetadataExtractor_OutputParam_Destroy"
29+ },
30+ {
31+ "first_introduced": "23",
32+ "name": "OH_AVMetadataExtractor_OutputParam_SetSize"
33+ },
34+ {
35+ "first_introduced": "23",
36+ "name": "OH_AVMetadataExtractor_FetchFrameByTime"
37+ },
38+ {
39+ "first_introduced": "23",
40+ "name": "OH_AVMetadataExtractor_FetchFramesByTimes"
41+ },
42+ {
43+ "first_introduced": "23",
44+ "name": "OH_AVMetadataExtractor_CancelAllFetchFrames"
45+ },
46+ {
47+ "first_introduced": "23",
48+ "name": "OH_AVMetadataExtractor_GetTrackDescription"
49+ },
50+ {
51+ "first_introduced": "23",
52+ "name": "OH_AVMetadataExtractor_GetCustomInfo"
53+ },
54+ {
55+ "first_introduced": "23",
56+ "name": "OH_AVMetadataExtractor_SetMediaSource"
57+ }
58+]
@@ -40,6 +40,7 @@
40#include <stdint.h>40#include <stdint.h>
41 41 
42#include "native_avformat.h"42#include "native_avformat.h"
43+#include "multimedia/image_framework/image/pixelmap_native.h"
43 44 
44#ifdef __cplusplus45#ifdef __cplusplus
45extern "C" {46extern "C" {
@@ -218,6 +219,47 @@ static const char* OH_AVMETADATA_EXTRACTOR_LOCATION_LATITUDE = "latitude";
218 */219 */
219static const char* OH_AVMETADATA_EXTRACTOR_LOCATION_LONGITUDE = "longitude";220static const char* OH_AVMETADATA_EXTRACTOR_LOCATION_LONGITUDE = "longitude";
220 221 
222+/**
223+ * @brief Enumerates the fetch frame result.
224+ *
225+ * @since 23
226+ */
227+typedef enum OH_AVMetadataExtractor_FetchState {
228+ /** Fetch operation is failed */
229+ OH_AVMETADATA_EXTRACTOR_FETCH_FAILED = 0,
230+ 
231+ /** Fetch operation is success */
232+ OH_AVMETADATA_EXTRACTOR_FETCH_SUCCEEDED = 1,
233+ 
234+ /** Fetch operation is cancelled by user*/
235+ OH_AVMETADATA_EXTRACTOR_FETCH_CANCELED = 2,
236+} OH_AVMetadataExtractor_FetchState;
237+ 
238+/**
239+ * @brief defines the output param for frames fetched by AVMetadataExtractor
240+ *
241+ * @since 23
242+ */
243+typedef struct OH_AVMetadataExtractor_OutputParam OH_AVMetadataExtractor_OutputParam;
244+ 
245+/**
246+ * @brief defines the frame info fetched from video
247+ *
248+ * @since 23
249+ */
250+typedef struct OH_AVMetadataExtractor_FrameInfo {
251+ /** The request time passed by user */
252+ int64_t requestTimeUs;
253+ /** The actual time for the fetched frame, -1 if failed to fetch */
254+ int64_t actualTimeUs;
255+
256+ /** The frame fetched from video, nullptr if failed to fecth */
257+ OH_PixelmapNative* image;
258+ 
259+ /** The frame fetched result */
260+ OH_AVMetadataExtractor_FetchState result;
261+} OH_AVMetadataExtractor_FrameInfo;
262+ 
221#ifdef __cplusplus263#ifdef __cplusplus
222}264}
223#endif265#endif
@@ -0,0 +1,157 @@
1+/*
2+ * Copyright (C) 2025 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+/**
17+ * @addtogroup avmetakeys
18+ * @{
19+ *
20+ * @brief Defines the avmetakeys.
21+ *
22+ * @syscap SystemCapability.Multimedia.Media.Core
23+ * @since 23
24+ */
25+ 
26+/**
27+ * @file avmetakeys.h
28+ *
29+ * @brief Defines the avmetakeys.
30+ *
31+ * @kit MediaKit
32+ * @library libavmedia_base.so
33+ * @syscap SystemCapability.Multimedia.Media.Core
34+ * @since 23
35+ */
36+ 
37+#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETAKEYS_H
38+#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETAKEYS_H
39+ 
40+#ifdef __cplusplus
41+extern "C" {
42+#endif
43+ 
44+/**
45+ * @brief Key for track index, value type is int32_t.
46+ * @since 23
47+ */
48+extern const char* OH_AVMETA_KEY_TRACK_INDEX;
49+ 
50+/**
51+ * @brief Key for track type, value type is int32_t
52+ * @since 23
53+ */
54+extern const char* OH_AVMETA_KEY_TRACK_TYPE;
55+ 
56+/**
57+ * @brief Key for codec mime type, value type is string.
58+ * @since 23
59+ */
60+extern const char* OH_AVMETA_KEY_MIME_TYPE;
61+ 
62+/**
63+ * @brief Key for duration, value type is int64_t.
64+ * @since 23
65+ */
66+extern const char* OH_AVMETA_KEY_DURATION;
67+ 
68+/**
69+ * @brief Key for bitrate, value type is int64_t.
70+ * @since 23
71+ */
72+extern const char* OH_AVMETA_KEY_BITRATE;
73+ 
74+/**
75+ * @brief Key for video frame rate (frame count in 100s), value type is double.
76+ * @since 23
77+ */
78+extern const char* OH_AVMETA_KEY_FRAME_RATE;
79+ 
80+/**
81+ * @brief Key for video width, value type is int32_t.
82+ * @since 23
83+ */
84+extern const char* OH_AVMETA_KEY_WIDTH;
85+ 
86+/**
87+ * @brief Key for video height, value type is int32_t.
88+ * @since 23
89+ */
90+extern const char* OH_AVMETA_KEY_HEIGHT;
91+ 
92+/**
93+ * @brief Key for audio channel count, value type is int32_t.
94+ * @since 23
95+ */
96+extern const char* OH_AVMETA_KEY_CHANNEL_COUNT;
97+ 
98+/**
99+ * @brief Key for audio sample rate (Hz), value type is int32_t.
100+ * @since 23
101+ */
102+extern const char* OH_AVMETA_KEY_SAMPLE_RATE;
103+ 
104+/**
105+ * @brief Key for audio bit depth, value type is int32_t.
106+ * @since 23
107+ */
108+extern const char* OH_AVMETA_KEY_SAMPLE_DEPTH;
109+ 
110+/**
111+ * @brief Key for language, value type is string.
112+ * @since 23
113+ */
114+extern const char* OH_AVMETA_KEY_LANGUAGE;
115+ 
116+/**
117+ * @brief Key for track name, value type is string.
118+ * @since 23
119+ */
120+extern const char* OH_AVMETA_KEY_TRACK_NAME;
121+ 
122+/**
123+ * @brief Key for hdr type, value type is int32_t.
124+ * @since 23
125+ */
126+extern const char* OH_AVMETA_KEY_HDR_TYPE;
127+ 
128+/**
129+ * @brief Key for original width, value type is int32_t.
130+ * @since 23
131+ */
132+extern const char* OH_AVMETA_KEY_ORIGINAL_WIDTH;
133+ 
134+/**
135+ * @brief Key for original height, value type is int32_t.
136+ * @since 23
137+ */
138+extern const char* OH_AVMETA_KEY_ORIGINAL_HEIGHT;
139+ 
140+/**
141+ * @brief Key to get the list of referenced track IDs. Only used by metadata extractor.
142+ * @since 23
143+ */
144+extern const char* OH_AVMETA_KEY_REF_TRACK_IDS;
145+ 
146+/**
147+ * @brief Key to get the track reference type. Only used by metadata extractor.
148+ * @since 23
149+ */
150+extern const char* OH_AVMETA_KEY_TRACK_REF_TYPE;
151+ 
152+#ifdef __cplusplus
153+}
154+#endif
155+ 
156+#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETAKEYS_H
157+/** @} */
@@ -48,6 +48,7 @@
48#include "native_window/external_window.h"48#include "native_window/external_window.h"
49#include "ohaudio/native_audiostream_base.h"49#include "ohaudio/native_audiostream_base.h"
50#include "native_avcodec_base.h"50#include "native_avcodec_base.h"
51+#include "avmedia_source.h"
51 52 
52#ifdef __cplusplus53#ifdef __cplusplus
53extern "C" {54extern "C" {
@@ -336,6 +337,16 @@ OH_AVErrCode OH_AVPlayer_SetPlaybackRate(OH_AVPlayer *player, float rate);
336 */337 */
337OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed);338OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed);
338 339 
340+/**
341+ * @brief get the current player playback rate
342+ * @param player Pointer to an OH_AVPlayer instance
343+ * @param rate the playback rate which can get.
344+ * @return Returns {@link AV_ERR_OK} if the current player playback rate is get; returns an error code defined
345+ * in {@link native_averrors.h} otherwise.
346+ * @since 23
347+ */
348+OH_AVErrCode OH_AVPlayer_GetPlaybackRate(OH_AVPlayer *player, float *rate);
349+ 
339/**350/**
340 * @brief Set the renderer information of the player's audio renderer351 * @brief Set the renderer information of the player's audio renderer
341 * @param player Pointer to an OH_AVPlayer instance352 * @param player Pointer to an OH_AVPlayer instance
@@ -706,6 +717,393 @@ OH_AVFormat *OH_AVPlayer_GetTrackDescription(OH_AVPlayer *player, uint32_t index
706 */717 */
707OH_AVFormat *OH_AVPlayer_GetPlaybackStatisticMetrics(OH_AVPlayer *player);718OH_AVFormat *OH_AVPlayer_GetPlaybackStatisticMetrics(OH_AVPlayer *player);
708 719 
720+/**
721+ * @brief Add subtitle resource represented by FD to the player. Currently, the external subtitle must be set after
722+ * fdSrc of the video resource is set in an AVPlayer instance.
723+ * @param {OH_AVPlayer} player Pointer to an OH_AVPlayer instance
724+ * @param {int32_t} fd Indicates the file descriptor of subtitle source.
725+ * @param {int64_t} offset Indicates the offset of media source in file descriptor.
726+ * @param {int64_t} size Indicates the size of media source.
727+ * @return Function result code.
728+ * {@link AV_ERR_OK} if the execution is successful.
729+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr.
730+ * @since 23
731+ */
732+OH_AVErrCode OH_AVPlayer_AddFdSubtitleSource(OH_AVPlayer *player, int32_t fd, int64_t offset, int64_t size);
733+ 
734+/**
735+ * @brief Add subtitle resource represented by url to the player. The external subtitle must be set after
736+ * url is set in an AVPlayer instance.
737+ * @param player Pointer to an OH_AVPlayer instance
738+ * @param url Indicates the url of subtitle source.
739+ * @return Function result code.
740+ * {@link AV_ERR_OK} if the execution is successful.
741+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr.
742+ * @since 23
743+ */
744+OH_AVErrCode OH_AVPlayer_AddUrlSubtitleSource(OH_AVPlayer *player, const char *url);
745+ 
746+/**
747+ * @brief Set playback start position and end position. After the setting, only the content in the specified range of
748+ * the audio or video file is played. It can be used in the initialized, prepared, paused, stopped, or completed state.
749+ * @param player Pointer to an OH_AVPlayer instance
750+ * @param mSecondsStart Playback start position, should be in [0, duration),
751+ * -1 means that the start position is not set, and the playback will start from 0.
752+ * @param mSecondsEnd Playback end position, which should usually be in (startTimeMs, duration],
753+ * -1 means that the end position is not set, and the playback will be ended at the end of the stream.
754+ * @param closestRange Use closest seek policy or not.
755+ * @return Function result code.
756+ * {@link AV_ERR_OK} if the execution is successful.
757+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr.
758+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed.
759+ * @since 23
760+ */
761+OH_AVErrCode OH_AVPlayer_SetPlaybackRange(OH_AVPlayer *player, int32_t mSecondsStart, int32_t mSecondsEnd,
762+ bool closestRange);
763+ 
764+/**
765+ * Mute the media stream. This API can be called only when the AVPlayer is in the prepared, playing,
766+ * paused, or completed state.
767+ * @param player Pointer to an OH_AVPlayer instance
768+ * @param mediaType Specified media type, see {@link OH_MediaType} in {@link native_avcodec_base.h}
769+ * @param muted true for mute, false for unmute.
770+ * @return Function result code.
771+ * {@link AV_ERR_OK} if the execution is successful.
772+ * {@link AV_ERR_INVALID_VAL} if input parameter is invalid.
773+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed.
774+ * @since 23
775+ */
776+OH_AVErrCode OH_AVPlayer_SetMediaMuted(OH_AVPlayer *player, OH_MediaType mediaType, bool muted);
777+ 
778+/**
779+ * @brief Get the playback position, accurate to millisecond. This API can be called only when the AVPlayer is in
780+ * the prepared, playing, paused, or completed state.
781+ * @param player Pointer to an OH_AVPlayer instance
782+ * @return Returns the playback position in milliseconds.
783+ * Return -1 if the player is nullptr or invalid.
784+ * @since 23
785+ */
786+int32_t OH_AVPlayer_GetPlaybackPosition(OH_AVPlayer *player);
787+ 
788+/**
789+ * @brief Checks whether the media source supports continuous seek.
790+ * The actual value is returned when this API is called in the prepared, playing, paused, or completed state.
791+ * The value **false** is returned if it is called in other states. For devices that do not support the seek
792+ * operation in {@link AV_SEEK_CONTINUOUS} mode, false is returned.
793+ * @param player Pointer to an OH_AVPlayer instance.
794+ * @return true - seek continuous is supported.
795+ * false - seek continuous is not supported or the support status is uncertain.
796+ * @since 23
797+ */
798+bool OH_AVPlayer_IsSeekContinuousSupported(OH_AVPlayer *player);
799+ 
800+/**
801+ * @brief Select track with switch mode when playing a resource with multiple audio and video tracks.
802+ * @param player Pointer to an OH_AVPlayer instance
803+ * @param index The selected track index.
804+ * @param mode The switch mode.
805+ * @return Function result code.
806+ * {@link AV_ERR_OK} if the execution is successful.
807+ * {@link AV_ERR_INVALID_VAL} if input parameter is invalid.
808+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed.
809+ * @since 23
810+ */
811+OH_AVErrCode OH_AVPlayer_SelectTrackWithMode(OH_AVPlayer *player, int32_t index, AVPlayerTrackSwitchMode mode);
812+ 
813+/**
814+ * @brief Subscribes to update events of the maximum audio level value, which is periodically reported when audio
815+ * resources are played.
816+ * @param player Pointer to an OH_AVPlayer instance
817+ * @param callback Pointer to callback function, nullptr indicates unregister callback.
818+ * @param userData Pointer to user specific data.
819+ * @return Function result code.
820+ * {@link AV_ERR_OK} if the execution is successful.
821+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr.
822+ * @since 23
823+ */
824+OH_AVErrCode OH_AVPlayer_SetAmplitudeUpdateCallback(OH_AVPlayer *player, OH_AVPlayerOnAmplitudeUpdateCallback callback,
825+ void *userData);
826+ 
827+/**
828+ * @brief Subscribes to events indicating that a Supplemental Enhancement Information (SEI) message is received. This
829+ * applies only to HTTP-FLV live streaming and is triggered when SEI messages are present in the video stream.
830+ * You must initiate the subscription before calling prepare.
831+ * @param player Pointer to an OH_AVPlayer instance
832+ * @param payloadTypes playload types
833+ * @param typeNum The size of the playload types array.
834+ * @param callback Pointer to callback function, nullptr indicates unregister callback.
835+ * @param userData Pointer to user specific data
836+ * @return Function result code.
837+ * {@link AV_ERR_OK} if the execution is successful.
838+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr.
839+ * @since 23
840+ */
841+OH_AVErrCode OH_AVPlayer_SetSeiReceivedCallback(OH_AVPlayer *player, const int32_t *payloadTypes, uint32_t typeNum,
842+ OH_AVPlayerOnSeiMessageReceivedCallback callback, void *userData);
843+ 
844+/**
845+ * @brief Get the number of message items in SEI message array.
846+ * @param message Pointer to an OH_AVSeiMessageArray instance
847+ * @return The number of message items in SEI message array
848+ * @since 23
849+ */
850+uint32_t OH_AVSeiMessage_GetSeiCount(OH_AVSeiMessageArray *message);
851+ 
852+/**
853+ * @brief Get SEI of the message item by index in SEI message array.
854+ * @param message Pointer to an OH_AVSeiMessageArray instance
855+ * @param index The index of the message item
856+ * @return The SEI of the message item
857+ * @since 23
858+ */
859+OH_AVFormat *OH_AVSeiMessage_GetSei(OH_AVSeiMessageArray *message, uint32_t index);
860+ 
861+/**
862+ * @brief Set video window size for super-resolution. This API can be called when the AVPlayer is in the initialized,
863+ * prepared, playing, paused, completed, or stopped state.The input parameter values must be in the range
864+ * of 320 x 320 to 1920 x 1080 (in px).
865+ * @param player Pointer to an OH_AVPlayer instance
866+ * @param width Width of the window. The value range is [320 - 1920], in px.
867+ * @param height Height of the window. The value range is [320 - 1080], in px.
868+ * @return Function result code.
869+ * {@link AV_ERR_OK} if the execution is successful.
870+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr, or Parameter errord.
871+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if Operation not allowed.
872+ * {@link AV_ERR_SUPER_RESOLUTION_UNSUPPORTED} if Super resolution is not supported.
873+ * {@link AV_ERR_SUPER_RESOLUTION_NOT_ENABLED} if Missing enable super resolution feature in{@link
874+ * PlaybackStrategy}.
875+ * @since 23
876+ */
877+OH_AVErrCode OH_AVPlayer_SetTargetVideoWindowSize(OH_AVPlayer *player, int32_t width, int32_t height);
878+ 
879+/**
880+ * @brief Enable or disable super-resolution dynamically. This API can be called when the AVPlayer is in the
881+ * initialized, prepared, playing, paused, completed, or stopped state.
882+ * Must enable super-resolution feature in {@link PlaybackStrategy} before calling prepare.
883+ * @param player Pointer to an OH_AVPlayer instance.
884+ * @param enabled true: super-resolution enabled; false: super-resolution disabled.
885+ * @return Function result code.
886+ * {@link AV_ERR_OK} if the execution is successful.
887+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr, or Parameter error.
888+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if Operation not allowed.
889+ * {@link AV_ERR_SUPER_RESOLUTION_UNSUPPORTED} if Super resolution is not supported.
890+ * {@link AV_ERR_SUPER_RESOLUTION_NOT_ENABLED} if Missing enable super resolution feature in{@link
891+ * PlaybackStrategy}.
892+ * @since 23
893+ */
894+OH_AVErrCode OH_AVPlayer_SetVideoSuperResolutionEnable(OH_AVPlayer *player, bool enabled);
895+ 
896+/**
897+ * @brief Create a playback strategy instance
898+ * @return a playback strategy instance, nullptr if fails.
899+ * @since 23
900+ */
901+OH_AVPlaybackStrategy *OH_AVPlaybackStrategy_Create(void);
902+ 
903+/**
904+ * @brief Release a playback strategy instance
905+ * @param strategy The OH_AVPlaybackStrategy instance.
906+ * @return Function result code.
907+ * {@link AV_ERR_OK} if the execution is successful.
908+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
909+ * @since 23
910+ */
911+OH_AVErrCode OH_AVPlaybackStrategy_Destroy(OH_AVPlaybackStrategy *strategy);
912+ 
913+/**
914+ * @brief Choose a stream width close to it.
915+ * @param strategy The OH_AVPlaybackStrategy used by avplayer.
916+ * @param width the preferred width chosen to play by avplayer at start.
917+ * @return Function result code.
918+ * {@link AV_ERR_OK} if the execution is successful.
919+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
920+ * @since 23
921+ */
922+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredWidth(OH_AVPlaybackStrategy *strategy, int32_t width);
923+ 
924+/**
925+ * @brief Choose a stream height close to it.
926+ * @param strategy The OH_AVPlaybackStrategy used by avplayer.
927+ * @param height The preferred width chosen to play by avplayer at start.
928+ * @return Function result code.
929+ * {@link AV_ERR_OK} if the execution is successful.
930+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
931+ * @since 23
932+ */
933+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredHeight(OH_AVPlaybackStrategy *strategy, int32_t height);
934+ 
935+/**
936+ * @brief Choose a preferred buffer duration close to it.
937+ * @param strategy The OH_AVPlaybackStrategy used by avplayer.
938+ * @param ms The preferred buffer duration chosen to play by avplayer at start.
939+ * @return Function result code.
940+ * {@link AV_ERR_OK} if the execution is successful.
941+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
942+ * @since 23
943+ */
944+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredBufferDuration(OH_AVPlaybackStrategy *strategy, int32_t ms);
945+ 
946+/**
947+ * @brief Enable or disable preferred HDR mode.
948+ *
949+ * @param strategy Pointer to OH_AVPlaybackStrategy.
950+ * @param enabled true to enable HDR, false to disable.
951+ * @return Function result code.
952+ * {@link AV_ERR_OK} if the execution is successful.
953+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
954+ * @since 23
955+ */
956+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredHdr(OH_AVPlaybackStrategy *strategy, bool enabled);
957+ 
958+/**
959+ * @brief Set preferred subtitle language.
960+ *
961+ * @param strategy Pointer to OH_AVPlaybackStrategy.
962+ * @param lang Subtitle language code (e.g., "zh").
963+ * @return Function result code.
964+ * {@link AV_ERR_OK} if the execution is successful.
965+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
966+ * @since 23
967+ */
968+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredSubtitleLanguage(OH_AVPlaybackStrategy *strategy, const char *lang);
969+ 
970+/**
971+ * @brief Set preferred audio language.
972+ *
973+ * @param strategy Pointer to OH_AVPlaybackStrategy.
974+ * @param lang Audio language code (e.g., "en").
975+ * @return Function result code.
976+ * {@link AV_ERR_OK} if the execution is successful.
977+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
978+ * @since 23
979+ */
980+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredAudioLanguage(OH_AVPlaybackStrategy *strategy, const char *lang);
981+ 
982+/**
983+ * @brief Set muted media type for playback.
984+ *
985+ * @param strategy Pointer to OH_AVPlaybackStrategy.
986+ * @param mediaType Media type to mute.
987+ * @return Function result code.
988+ * {@link AV_ERR_OK} if the execution is successful.
989+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
990+ * @since 23
991+ */
992+OH_AVErrCode OH_AVPlaybackStrategy_SetMutedMediaType(OH_AVPlaybackStrategy *strategy, OH_MediaType mediaType);
993+ 
994+/**
995+ * @brief Set whether to show the first frame on prepare.
996+ *
997+ * @param strategy Pointer to OH_AVPlaybackStrategy.
998+ * @param enabled true to show, false otherwise.
999+ * @return Function result code.
1000+ * {@link AV_ERR_OK} if the execution is successful.
1001+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
1002+ * @since 23
1003+ */
1004+OH_AVErrCode OH_AVPlaybackStrategy_SetShowFirstFrameOnPrepare(OH_AVPlaybackStrategy *strategy, bool enabled);
1005+ 
1006+/**
1007+ * @brief Set the threshold for auto quick play.
1008+ *
1009+ * @param strategy Pointer to OH_AVPlaybackStrategy.
1010+ * @param seconds Threshold value.
1011+ * @return Function result code.
1012+ * {@link AV_ERR_OK} if the execution is successful.
1013+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
1014+ * @since 23
1015+ */
1016+OH_AVErrCode OH_AVPlaybackStrategy_SetThresholdForAutoQuickPlay(OH_AVPlaybackStrategy *strategy, double seconds);
1017+ 
1018+/**
1019+ * @brief Enable or disable super resolution.
1020+ *
1021+ * @param strategy Pointer to OH_AVPlaybackStrategy.
1022+ * @param enabled true to enable, false to disable.
1023+ * @return Function result code.
1024+ * {@link AV_ERR_OK} if the execution is successful.
1025+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
1026+ * @since 23
1027+ */
1028+OH_AVErrCode OH_AVPlaybackStrategy_SetSuperResolutionEnable(OH_AVPlaybackStrategy *strategy, bool enabled);
1029+ 
1030+/**
1031+ * @brief Set preferred buffer duration for playing in seconds (double).
1032+ *
1033+ * @param strategy Pointer to OH_AVPlaybackStrategy.
1034+ * @param seconds Buffer duration in seconds.
1035+ * @return Function result code.
1036+ * {@link AV_ERR_OK} if the execution is successful.
1037+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
1038+ * @since 23
1039+ */
1040+OH_AVErrCode OH_AVPlaybackStrategy_SetPreferredBufferDurationForPlaying(OH_AVPlaybackStrategy *strategy,
1041+ double seconds);
1042+ 
1043+/**
1044+ * @brief Set whether to keep decoding when muted.
1045+ *
1046+ * @param strategy Pointer to OH_AVPlaybackStrategy.
1047+ * @param enabled true to keep decoding, false to pause decoding when muted.
1048+ * @return Function result code.
1049+ * {@link AV_ERR_OK} if the execution is successful.
1050+ * {@link AV_ERR_INVALID_VAL} if input strategy is nullptr.
1051+ * @since 23
1052+ */
1053+OH_AVErrCode OH_AVPlaybackStrategy_SetKeepDecodingOnMute(OH_AVPlaybackStrategy *strategy, bool enabled);
1054+ 
1055+/**
1056+ * @brief Set playback strategy to avplayer. This API can be called only when the avplayer is in the initialized state.
1057+ * @param player Pointer to an OH_AVPlayer instance
1058+ * @param strategy The playback strategy instance.
1059+ * @return Function result code.
1060+ * {@link AV_ERR_OK} if the execution is successful.
1061+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr.
1062+ * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed.
1063+ * @since 23
1064+ */
1065+OH_AVErrCode OH_AVPlayer_SetPlaybackStrategy(OH_AVPlayer *player, OH_AVPlaybackStrategy *strategy);
1066+ 
1067+/**
1068+ * @brief Get statistic info of current player. This API can be called only when the avplayer is in the prepared,
1069+ * playing, or paused state.
1070+ * @param {OH_AVPlayer*} player Pointer to an OH_AVPlayer instance
1071+ * @return Returns a pointer to an OH_AVFormat instance.
1072+ * Return nullptr if the player is nullptr or invalid.
1073+ * @since 23
1074+ */
1075+OH_AVFormat* OH_AVPlayer_GetPlaybackInfo(OH_AVPlayer *player);
1076+ 
1077+/**
1078+ * @brief Sets an OH_AVMediaSource to the player.
1079+ * @param player Pointer to an OH_AVPlayer instance.
1080+ * @param source Indicates the media source.
1081+ * @return Function result code.
1082+ * {@link AV_ERR_OK} if the execution is successful.
1083+ * {@link AV_ERR_INVALID_VAL} if input player is nullptr, source is null or player setUrlSource failed.
1084+ * @since 23
1085+ */
1086+OH_AVErrCode OH_AVPlayer_SetMediaSource(OH_AVPlayer *player, OH_AVMediaSource *source);
1087+ 
1088+/**
1089+ * @brief Get the track count of player media source.
1090+ * @param player Pointer to an OH_AVPlayer instance
1091+ * @return Returns the track count.
1092+ * @since 23
1093+ */
1094+uint32_t OH_AVPlayer_GetTrackCount(OH_AVPlayer *player);
1095+ 
1096+/**
1097+ * @brief Get the player track info by the index.
1098+ * @param player Pointer to an OH_AVPlayer instance
1099+ * @param trackIndex Indicates tracks array index.
1100+ * @return Returns a pointer to an OH_AVFormat instance.
1101+ * Return nullptr if the player is nullptr or invalid.
1102+ * Return nullptr if the trackIndex is invalid.
1103+ * @since 23
1104+ */
1105+OH_AVFormat *OH_AVPlayer_GetTrackFormat(OH_AVPlayer *player, uint32_t trackIndex);
1106+ 
709#ifdef __cplusplus1107#ifdef __cplusplus
710}1108}
711#endif1109#endif
@@ -107,6 +107,58 @@
107 "first_introduced": "12",107 "first_introduced": "12",
108 "name": "OH_PLAYER_IS_LIVE_STREAM"108 "name": "OH_PLAYER_IS_LIVE_STREAM"
109 },109 },
110+ {
111+ "first_introduced": "23",
徐学军2025年12月24日

不是函数,要加变量标识

likedislike
112+ "name": "OH_PLAYER_SEI_PAYLOAD_TYPE"
113+ },
114+ {
115+ "first_introduced": "23",
116+ "name": "OH_PLAYER_SEI_PAYLOAD_CONTENT"
117+ },
118+ {
119+ "first_introduced": "23",
120+ "name": "OH_PLAYER_SUPER_RESOLUTION_ENABLE_STATE"
121+ },
122+ {
123+ "first_introduced": "23",
124+ "name": "OH_PLAYER_TRACH_CHANGE_INFO_TRACK_INDEX"
125+ },
126+ {
127+ "first_introduced": "23",
128+ "name": "OH_PLAYER_TRACH_CHANGE_INFO_TRACK_SELECTED"
129+ },
130+ {
131+ "first_introduced": "23",
132+ "name": "OH_PLAYER_SUBTITLE_UPDATE_INFO_DURATION"
133+ },
134+ {
135+ "first_introduced": "23",
136+ "name": "OH_PLAYER_SUBTITLE_UPDATE_INFO_START_TIME"
137+ },
138+ {
139+ "first_introduced": "23",
140+ "name": "OH_PLAYER_SUBTITLE_UPDATE_INFO_TEXT"
141+ },
142+ {
143+ "first_introduced": "23",
144+ "name": "OH_PLAYER_SERVER_IP_ADDRESS"
145+ },
146+ {
147+ "first_introduced": "23",
148+ "name": "OH_PLAYER_IS_DOWNLOADING"
149+ },
150+ {
151+ "first_introduced": "23",
152+ "name": "OH_PLAYER_BUFFER_DURATION"
153+ },
154+ {
155+ "first_introduced": "23",
156+ "name": "OH_PLAYER_DOWNLOAD_RATE"
157+ },
158+ {
159+ "first_introduced": "23",
160+ "name": "OH_PLAYER_AVG_DOWNLOAD_RATE"
徐学军2025年12月24日

不是函数,要加变量标识 总共10+处,一起修改

likedislike
161+ },
110 {162 {
111 "first_introduced": "12",163 "first_introduced": "12",
112 "name": "OH_AVPlayer_SetOnInfoCallback"164 "name": "OH_AVPlayer_SetOnInfoCallback"
@@ -202,5 +254,137 @@
202 {254 {
203 "first_introduced": "23",255 "first_introduced": "23",
204 "name": "OH_MEDIA_EVENT_INFO_TOTAL_STALLING_TIME"256 "name": "OH_MEDIA_EVENT_INFO_TOTAL_STALLING_TIME"
257+ },
258+ {
259+ "first_introduced": "23",
260+ "name": "OH_AVPlayer_AddFdSubtitleSource"
261+ },
262+ {
263+ "first_introduced": "23",
264+ "name": "OH_AVPlayer_AddUrlSubtitleSource"
265+ },
266+ {
267+ "first_introduced": "23",
268+ "name": "OH_AVPlayer_SetPlaybackRange"
269+ },
270+ {
271+ "first_introduced": "23",
272+ "name": "OH_AVPlayer_SetMediaMuted"
273+ },
274+ {
275+ "first_introduced": "23",
276+ "name": "OH_AVPlayer_GetPlaybackPosition"
277+ },
278+ {
279+ "first_introduced": "23",
280+ "name": "OH_AVPlayer_IsSeekContinuousSupported"
281+ },
282+ {
283+ "first_introduced": "23",
284+ "name": "OH_AVPlayer_SelectTrackWithMode"
285+ },
286+ {
287+ "first_introduced": "23",
288+ "name": "OH_AVPlayer_SetAmplitudeUpdateCallback"
289+ },
290+ {
291+ "first_introduced": "23",
292+ "name": "OH_AVPlayer_SetSeiReceivedCallback"
293+ },
294+ {
295+ "first_introduced": "23",
296+ "name": "OH_AVSeiMessage_GetSeiCount"
297+ },
298+ {
299+ "first_introduced": "23",
300+ "name": "OH_AVSeiMessage_GetSei"
301+ },
302+ {
303+ "first_introduced": "23",
304+ "name": "OH_AVPlayer_SetTargetVideoWindowSize"
305+ },
306+ {
307+ "first_introduced": "23",
308+ "name": "OH_AVPlayer_SetVideoSuperResolutionEnable"
309+ },
310+ {
311+ "first_introduced": "23",
312+ "name": "OH_AVPlaybackStrategy_Create"
313+ },
314+ {
315+ "first_introduced": "23",
316+ "name": "OH_AVPlaybackStrategy_Destroy"
317+ },
318+ {
319+ "first_introduced": "23",
320+ "name": "OH_AVPlaybackStrategy_SetPreferredWidth"
321+ },
322+ {
323+ "first_introduced": "23",
324+ "name": "OH_AVPlaybackStrategy_SetPreferredHeight"
325+ },
326+ {
327+ "first_introduced": "23",
328+ "name": "OH_AVPlaybackStrategy_SetPreferredBufferDuration"
329+ },
330+ {
331+ "first_introduced": "23",
332+ "name": "OH_AVPlaybackStrategy_SetPreferredHdr"
333+ },
334+ {
335+ "first_introduced": "23",
336+ "name": "OH_AVPlaybackStrategy_SetPreferredSubtitleLanguage"
337+ },
338+ {
339+ "first_introduced": "23",
340+ "name": "OH_AVPlaybackStrategy_SetPreferredAudioLanguage"
341+ },
342+ {
343+ "first_introduced": "23",
344+ "name": "OH_AVPlaybackStrategy_SetMutedMediaType"
345+ },
346+ {
347+ "first_introduced": "23",
348+ "name": "OH_AVPlaybackStrategy_SetShowFirstFrameOnPrepare"
349+ },
350+ {
351+ "first_introduced": "23",
352+ "name": "OH_AVPlaybackStrategy_SetThresholdForAutoQuickPlay"
353+ },
354+ {
355+ "first_introduced": "23",
356+ "name": "OH_AVPlaybackStrategy_SetSuperResolutionEnable"
357+ },
358+ {
359+ "first_introduced": "23",
360+ "name": "OH_AVPlaybackStrategy_SetPreferredBufferDurationForPlaying"
361+ },
362+ {
363+ "first_introduced": "23",
364+ "name": "OH_AVPlaybackStrategy_SetKeepDecodingOnMute"
365+ },
366+ {
367+ "first_introduced": "23",
368+ "name": "OH_AVPlayer_SetPlaybackStrategy"
369+ },
370+ {
371+ "first_introduced": "23",
372+ "name": "OH_AVPlayer_GetPlaybackInfo"
373+ },
374+ {
375+ "first_introduced": "23",
376+ "name": "OH_AVPlayer_SetMediaSource"
377+ },
378+ {
379+ "first_introduced": "23",
380+ "name": "OH_AVPlayer_GetTrackCount"
381+ },
382+ {
383+ "first_introduced": "23",
384+ "name": "OH_AVPlayer_GetTrackFormat"
385+ },
386+ {
387+ "first_introduced": "23",
388+ "name": "OH_AVPlayer_GetPlaybackRate"
205 }389 }
206]390]
@@ -1,5 +1,5 @@
1/*1/*
2- * Copyright (C) 2023 Huawei Device Co., Ltd.2+ * Copyright (C) 2023-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at5 * You may obtain a copy of the License at
@@ -49,6 +49,18 @@ extern "C" {
49 49 
50typedef struct OH_AVPlayer OH_AVPlayer;50typedef struct OH_AVPlayer OH_AVPlayer;
51 51 
52+/**
53+ * @brief OH_AVSeiMessageArray field.
54+ * @since 23
55+ */
56+typedef struct OH_AVSeiMessageArray OH_AVSeiMessageArray;
57+ 
58+/**
59+ * @brief OH_AVPlaybackStrategy field.
60+ * @since 23
61+ */
62+typedef struct OH_AVPlaybackStrategy OH_AVPlaybackStrategy;
63+ 
52/**64/**
53 * @brief Player States65 * @brief Player States
54 * @syscap SystemCapability.Multimedia.Media.AVPlayer66 * @syscap SystemCapability.Multimedia.Media.AVPlayer
@@ -93,6 +105,13 @@ typedef enum AVPlayerSeekMode {
93 * @since 12105 * @since 12
94 */106 */
95 AV_SEEK_CLOSEST = 2,107 AV_SEEK_CLOSEST = 2,
108+ /**
109+ * Seek in continuous mode, which can provide a smoother dragging experience, but the device needs to support
110+ * the current stream to execute seek continuous. Before calling seek continuous,
111+ * check whether it is supported, see {@link #OH_AVPlayer_IsSeekContinuousSupported}.
112+ * @since 23
113+ */
114+ AV_SEEK_CONTINUOUS = 3,
96} AVPlayerSeekMode;115} AVPlayerSeekMode;
97 116 
98/**117/**
@@ -200,6 +219,12 @@ typedef enum AVPlayerOnInfoType {
200 * @since 20219 * @since 20
201 */220 */
202 AV_INFO_TYPE_PLAYBACK_RATE_DONE = 18,221 AV_INFO_TYPE_PLAYBACK_RATE_DONE = 18,
222+ /**
223+ * @brief Super-resolution changed info type.
224+ *
225+ * @since 23
226+ */
227+ AV_INFO_TYPE_SUPER_RESOLUTION_CHANGED = 19,
203} AVPlayerOnInfoType;228} AVPlayerOnInfoType;
204 229 
205/**230/**
@@ -222,6 +247,19 @@ typedef enum AVPlayerBufferingType {
222 AVPLAYER_BUFFERING_CACHED_DURATION,247 AVPLAYER_BUFFERING_CACHED_DURATION,
223} AVPlayerBufferingType;248} AVPlayerBufferingType;
224 249 
250+/**
251+ * @brief Enumerates the track switch mode
252+ * @since 23
253+ */
254+typedef enum AVPlayerTrackSwitchMode {
255+ /** Switch track smoothly */
256+ AV_TRACK_SWITCH_MODE_SMOOTH = 0,
257+ /** Switch track segment */
258+ AV_TRACK_SWITCH_MODE_SEGMENT = 1,
259+ /** Switch track closest */
260+ AV_TRACK_SWITCH_MODE_CLOSEST = 2,
261+} AVPlayerTrackSwitchMode;
262+ 
225/**263/**
226 * @brief Key to get state, value type is int32_t.264 * @brief Key to get state, value type is int32_t.
227 * @syscap SystemCapability.Multimedia.Media.AVPlayer265 * @syscap SystemCapability.Multimedia.Media.AVPlayer
@@ -403,6 +441,86 @@ extern const char* OH_PLAYER_MD_KEY_HAS_SUBTITLE;
403 */441 */
404extern const char* OH_PLAYER_MD_KEY_TRACK_INDEX;442extern const char* OH_PLAYER_MD_KEY_TRACK_INDEX;
405 443 
444+/**
445+ * Sei message key for payload type.
446+ * @since 23
447+ */
448+extern const char* OH_PLAYER_SEI_PAYLOAD_TYPE;
449+ 
450+/**
451+ * Sei message key for payload content.
452+ * @since 23
453+ */
454+extern const char* OH_PLAYER_SEI_PAYLOAD_CONTENT;
455+ 
456+/**
457+ * @brief Key to get whether the super resolution feature is enabled,
458+ * value type is int32_t. The value is 1 when enabled, otherwise 0.
459+ * Used in the info callback when super resolution state changes.
460+ * @since 23
461+ */
462+extern const char* OH_PLAYER_SUPER_RESOLUTION_ENABLE_STATE;
463+ 
464+/**
465+ * @brief Track change info key for track info, its value is int32_t type.
466+ * @since 23
467+ */
468+extern const char* OH_PLAYER_TRACH_CHANGE_INFO_TRACK_INDEX;
469+ 
470+/**
471+ * @brief Track change info key for track selected flag, its value is int32_t type.
472+ * @since 23
473+ */
474+extern const char* OH_PLAYER_TRACH_CHANGE_INFO_TRACK_SELECTED;
475+ 
476+/**
477+ * @brief Subtitle update info key for duration, its value is int32_t type.
478+ * @since 23
479+ */
480+extern const char* OH_PLAYER_SUBTITLE_UPDATE_INFO_DURATION;
481+ 
482+/**
483+ * @brief Subtitle update info key for start time, its value is int32_t type.
484+ * @since 23
485+ */
486+extern const char* OH_PLAYER_SUBTITLE_UPDATE_INFO_START_TIME;
487+ 
488+/**
489+ * @brief Subtitle update info key for subtitle text, its value is string type.
490+ * @since 23
491+ */
492+extern const char* OH_PLAYER_SUBTITLE_UPDATE_INFO_TEXT;
493+ 
494+/**
495+ * Playback info key for server ip address.
496+ * @since 23
497+ */
498+extern const char* OH_PLAYER_SERVER_IP_ADDRESS;
499+ 
500+/**
501+ * Playback info key for downloading state.
502+ * @since 23
503+ */
504+extern const char* OH_PLAYER_IS_DOWNLOADING;
505+ 
506+/**
507+ * Playback info key for buffer duration.
508+ * @since 23
509+ */
510+extern const char* OH_PLAYER_BUFFER_DURATION;
511+ 
512+/**
513+ * Playback info key for download rate.
514+ * @since 23
515+ */
516+extern const char* OH_PLAYER_DOWNLOAD_RATE;
517+ 
518+/**
519+ * Playback info key for average download rate.
520+ * @since 23
521+ */
522+extern const char* OH_PLAYER_AVG_DOWNLOAD_RATE;
523+ 
406/**524/**
407 * @brief Called when a player message or alarm is received.525 * @brief Called when a player message or alarm is received.
408 * @syscap SystemCapability.Multimedia.Media.AVPlayer526 * @syscap SystemCapability.Multimedia.Media.AVPlayer
@@ -453,6 +571,29 @@ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const
453typedef void (*OH_AVPlayerOnErrorCallback)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg,571typedef void (*OH_AVPlayerOnErrorCallback)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg,
454 void *userData);572 void *userData);
455 573 
574+/**
575+ * @brief Called when the maximum audio level values are calculated.
576+ * @param player Pointer to an OH_AVPlayer instance.
577+ * @param amplitudes The pointer to the maximum audio level values array.
578+ * @param size The size of the maximum audio level values array.
579+ * @param userData Pointer to user specific data.
580+ * @since 23
581+ */
582+typedef void (*OH_AVPlayerOnAmplitudeUpdateCallback)(OH_AVPlayer *player, double *amplitudes, uint32_t size,
583+ void *userData);
584+ 
585+/**
586+ * @brief Describes the handle used to obtain SEI messages. This is used when in subscriptions to SEI message events.
587+ * and the callback returns detailed SEI information.
588+ * @param player Pointer to an OH_AVPlayer instance
589+ * @param message SEI message array
590+ * @param playbackPosition playback position
591+ * @param userData Pointer to user specific data
592+ * @since 23
593+ */
594+typedef void (*OH_AVPlayerOnSeiMessageReceivedCallback)(OH_AVPlayer *player, OH_AVSeiMessageArray *message,
595+ int32_t playbackPosition, void *userData);
596+ 
456/**597/**
457 * @brief A collection of all callback function pointers in OH_AVPlayer. Register an instance of this598 * @brief A collection of all callback function pointers in OH_AVPlayer. Register an instance of this
458 * structure to the OH_AVPlayer instance, and process the information reported through the callback to ensure the599 * structure to the OH_AVPlayer instance, and process the information reported through the callback to ensure the
@@ -152,6 +152,10 @@ _ndk_library_targets = [
152 "//interface/sdk_c/multimedia/player_framework/avrecorder:avrecorder_header",152 "//interface/sdk_c/multimedia/player_framework/avrecorder:avrecorder_header",
153 "//interface/sdk_c/multimedia/player_framework/avmetadata_extractor:libavmetadata_extractor",153 "//interface/sdk_c/multimedia/player_framework/avmetadata_extractor:libavmetadata_extractor",
154 "//interface/sdk_c/multimedia/player_framework/avmetadata_extractor:avmetadata_extractor_header",154 "//interface/sdk_c/multimedia/player_framework/avmetadata_extractor:avmetadata_extractor_header",
155+ "//interface/sdk_c/multimedia/player_framework/avmedia_source:libavmedia_source",
156+ "//interface/sdk_c/multimedia/player_framework/avmedia_source:avmedia_source_header",
157+ "//interface/sdk_c/multimedia/player_framework/avmedia_base:libavmedia_base",
158+ "//interface/sdk_c/multimedia/player_framework/avmedia_base:avmedia_base_header",
155 "//interface/sdk_c/multimedia/player_framework/avimage_generator:libavimage_generator",159 "//interface/sdk_c/multimedia/player_framework/avimage_generator:libavimage_generator",
156 "//interface/sdk_c/multimedia/player_framework/avimage_generator:avimage_generator_header",160 "//interface/sdk_c/multimedia/player_framework/avimage_generator:avimage_generator_header",
157 "//interface/sdk_c/multimedia/player_framework/avtranscoder:libavtranscoder",161 "//interface/sdk_c/multimedia/player_framework/avtranscoder:libavtranscoder",