1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef TEST_NDK_SCREEN_CAPTURE_H 17 #define TEST_NDK_SCREEN_CAPTURE_H 18 19 #include <fcntl.h> 20 #include <thread> 21 #include <cstdio> 22 #include <iostream> 23 #include "nativetoken_kit.h" 24 #include "accesstoken_kit.h" 25 #include "token_setproc.h" 26 #include "native_avscreen_capture.h" 27 #include "native_avscreen_capture_base.h" 28 #include "native_avscreen_capture_errors.h" 29 #include "aw_common.h" 30 #include "media_errors.h" 31 32 namespace OHOS { 33 namespace Media { 34 #define RETURN_IF(cond, ret, ...) \ 35 do { \ 36 if (!(cond)) { \ 37 return ret; \ 38 } \ 39 } while (0) 40 41 class TestNdkScreenCapture : public NoCopyable { 42 public: 43 TestNdkScreenCapture(); 44 ~TestNdkScreenCapture(); 45 }; 46 47 class TestScreenCaptureNdkCallback : public OH_AVScreenCaptureCallback, public NoCopyable { 48 public: TestScreenCaptureNdkCallback()49 TestScreenCaptureNdkCallback() {} 50 ~TestScreenCaptureNdkCallback() = default; 51 static void OnError(OH_AVScreenCapture *screenCapture, int32_t errorCode); 52 static void OnAudioBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady, OH_AudioCaptureSourceType type); 53 static void OnVideoBufferAvailable(OH_AVScreenCapture *screenCapture, bool isReady); 54 }; 55 } // namespace Media 56 } // namespace OHOS 57 #endif