diff --git a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json index f00ca3838ad49102f2e6af120cc9cf8f277304a3..f3fa01d665e7862ed3c3f9e2a283b067360b85b3 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -1,15 +1,74 @@ [ - { "name": "OH_AVScreenCapture_Create" }, - { "name": "OH_AVScreenCapture_Init" }, - { "name": "OH_AVScreenCapture_StartScreenCapture" }, - { "name": "OH_AVScreenCapture_StopScreenCapture" }, - { "name": "OH_AVScreenCapture_StartScreenRecording" }, - { "name": "OH_AVScreenCapture_StopScreenRecording" }, - { "name": "OH_AVScreenCapture_AcquireAudioBuffer" }, - { "name": "OH_AVScreenCapture_AcquireVideoBuffer" }, - { "name": "OH_AVScreenCapture_ReleaseAudioBuffer" }, - { "name": "OH_AVScreenCapture_ReleaseVideoBuffer" }, - { "name": "OH_AVScreenCapture_SetCallback" }, - { "name": "OH_AVScreenCapture_Release" }, - { "name": "OH_AVScreenCapture_SetMicrophoneEnabled" } + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_Create" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_Init" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_StartScreenCapture" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_StopScreenCapture" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_StartScreenRecording" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_StopScreenRecording" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_AcquireAudioBuffer" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_AcquireVideoBuffer" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_ReleaseAudioBuffer" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_ReleaseVideoBuffer" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_SetCallback" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_Release" + }, + { + "first_introduced": "10", + "name": "OH_AVScreenCapture_SetMicrophoneEnabled" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_StartScreenCaptureWithSurface" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SetCanvasRotation" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SetStateCallback" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SetDataCallback" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SetErrorCallback" + } ] \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 22837a29dac5448236f11f5a47ce624914e94396..fdb1e76020ad62ef70f8953a97e58eeff4fa257d 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -20,6 +20,7 @@ #include #include "native_avscreen_capture_errors.h" #include "native_avscreen_capture_base.h" +#include "external_window.h" #ifdef __cplusplus extern "C" { @@ -184,6 +185,123 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture, bool isMicrophone); +/** + * @brief Set the state callback function so that your application can respond to the + * state change events generated by the av screen capture. This interface must be called before Start is called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param callback State callback function, see {@link OH_AVScreenCapture_OnStateChange} + * @param userData Pointer to user specific data + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback(struct OH_AVScreenCapture *capture, + OH_AVScreenCapture_OnStateChange callback, void *userData); + +/** + * @brief Set the data callback function so that your application can respond to the + * data available events generated by the av screen capture. This interface must be called before Start is called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param callback Data callback function, see {@link OH_AVScreenCapture_OnBufferAvailable} + * @param userData Pointer to user specific data + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback(struct OH_AVScreenCapture *capture, + OH_AVScreenCapture_OnBufferAvailable callback, void *userData); + +/** + * @brief Set the error callback function so that your application can respond to the + * error events generated by the av screen capture. This interface must be called before Start is called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param callback Error callback function, see {@link OH_AVScreenCapture_OnError} + * @param userData Pointer to user specific data + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback(struct OH_AVScreenCapture *capture, + OH_AVScreenCapture_OnError callback, void *userData); + +/** + * @brief Start the av screen capture, video data provided by OHNativeWindow + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param window Pointer to an OHNativeWindow instance + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCaptureWithSurface(struct OH_AVScreenCapture *capture, + OHNativeWindow *window); + +/** + * @brief Set canvas rotation when capturing screen + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param canvasRotation whether to rotate the canvas + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCanvasRotation(struct OH_AVScreenCapture *capture, + bool canvasRotation); + +/** + * @brief Create a screen capture content filter + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @return Returns a pointer to an OH_AVScreenCapture_ContentFilter instance + * @since 12 + * @version 1.0 + */ +struct OH_AVScreenCapture_ContentFilter *OH_AVScreenCapture_CreateContentFilter(void); + +/** + * @brief Release the screen capture content filter + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseContentFilter(struct OH_AVScreenCapture_ContentFilter *filter); + +/** + * @brief Add content to the screen capture content filter + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance + * @param content content to be added + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddAudioContent( + struct OH_AVScreenCapture_ContentFilter *filter, OH_AVScreenCaptureFilterableAudioContent content); + +/** + * @brief Set content filter to screen capture + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param filter Pointer to an OH_AVScreenCapture_ContentFilter instance + * @return Returns AV_SCREEN_CAPTURE_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode} + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ExcludeContent(struct OH_AVScreenCapture *capture, + struct OH_AVScreenCapture_ContentFilter *filter); + #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/native_avscreen_capture_base.h b/multimedia/player_framework/native_avscreen_capture_base.h index 97b27e3f16aea7201b30461c3140cf6595305765..918763868295ab730a3bf350737964598a6f3fd8 100644 --- a/multimedia/player_framework/native_avscreen_capture_base.h +++ b/multimedia/player_framework/native_avscreen_capture_base.h @@ -16,6 +16,9 @@ #ifndef NATIVE_AVSCREEN_CAPTURE_BASE_H #define NATIVE_AVSCREEN_CAPTURE_BASE_H +#include +#include "native_avbuffer.h" + #ifdef __cplusplus extern "C" { #endif @@ -38,6 +41,15 @@ typedef struct OH_NativeBuffer OH_NativeBuffer; */ typedef struct OH_AVScreenCapture OH_AVScreenCapture; +/** + * @brief Initialization of OH_AVScreenCapture_ContentFilter + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_AVScreenCapture_ContentFilter OH_AVScreenCapture_ContentFilter; + /** * @brief Enumerates screen capture mode. * @syscap SystemCapability.Multimedia.Media.AVScreenCapture @@ -387,6 +399,104 @@ typedef struct OH_AudioBuffer { OH_AudioCaptureSourceType type; } OH_AudioBuffer; +/** + * @brief Enumerates screen capture state code. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 12 + * @version 1.0 + */ +typedef enum OH_AVScreenCaptureStateCode { + /* Screen capture started by user */ + OH_SCREEN_CAPTURE_STATE_STARTED = 0, + /* Screen capture canceled by user */ + OH_SCREEN_CAPTURE_STATE_CANCELED = 1, + /* ScreenCapture stopped by user */ + OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER = 2, + /* ScreenCapture interrupted by other screen capture */ + OH_SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER = 3, + /* ScreenCapture stopped by SIM call */ + OH_SCREEN_CAPTURE_STATE_STOPPED_BY_CALL = 4, + /* Microphone is temporarily unavailable */ + OH_SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE = 5, + /* Microphone is muted by user */ + OH_SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER = 6, + /* Microphone is unmuted by user */ + OH_SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER = 7, + /* Current captured screen has private window */ + OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE = 8, + /* Private window disappeared on current captured screen*/ + OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE = 9, +} OH_AVScreenCaptureStateCode; + +/** + * @brief Enumerates screen capture buffer type. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 12 + * @version 1.0 + */ +typedef enum OH_AVScreenCaptureBufferType { + /* Buffer of video data from screen */ + OH_SCREEN_CAPTURE_BUFFERTYPE_VIDEO = 0, + /* Buffer of audio data from inner capture */ + OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_INNER = 1, + /* Buffer of audio data from microphone */ + OH_SCREEN_CAPTURE_BUFFERTYPE_AUDIO_MIC = 2, +} OH_AVScreenCaptureBufferType; + +/** + * @brief Enumerates screen capture buffer type. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * + * @since 12 + * @version 1.0 + */ +typedef enum OH_AVScreenCaptureFilterableAudioContent { + /* Audio content of notification sound */ + OH_SCREEN_CAPTURE_NOTIFICATION_AUDIO = 0, +} OH_AVScreenCaptureFilterableAudioContent; + +/** + * @brief When state of OH_AVScreenCapture is changed, the function pointer will be called. + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param stateCode Information describing current state, see {@link OH_AVScreenCaptureStateCode} + * @param userData Pointer to user specific data + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_AVScreenCapture_OnStateChange)(struct OH_AVScreenCapture *capture, + OH_AVScreenCaptureStateCode stateCode, void *userData); + +/** + * @brief When an error occurs in the running of the OH_AVScreenCapture instance, the function pointer will be called + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param errorCode specific error code + * @param userData Pointer to user specific data + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_AVScreenCapture_OnError)(OH_AVScreenCapture *capture, int32_t errorCode, void *userData); + +/** + * @brief When data is ready from the OH_AVScreenCapture instance, the function pointer will be called + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param buffer Pointer to a buffer containing media data + * @param bufferType Data type of the buffer, see {@link OH_AVScreenCaptureBufferType} + * @param timestamp Timestamp of the buffer + * @param userData Pointer to user specific data + * + * @since 12 + * @version 1.0 + */ +typedef void (*OH_AVScreenCapture_OnBufferAvailable)(OH_AVScreenCapture *capture, OH_AVBuffer *buffer, + OH_AVScreenCaptureBufferType bufferType, int64_t timestamp, void *userData); + #ifdef __cplusplus } #endif