diff --git a/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerAPITest.h b/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerAPITest.h index b47e9d21d02dc8b0aa51b841c8de10ebc8d3df94..085ea5e15db51919330ca3e24f3370460d6d564d 100755 --- a/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerAPITest.h +++ b/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerAPITest.h @@ -15,7 +15,7 @@ #ifndef PLAYER_API_TEST_H #define PLAYER_API_TEST_H -#include "Testplayer.h" +#include "TestPlayer.h" namespace OHOS { namespace Media { diff --git a/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h b/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h index 6a44256497419c7fbca62fbcaf142699b340e413..8338da368aebfdc0df4dfcdcfdb53143a7a9cef1 100755 --- a/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h +++ b/multimedia/media/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h @@ -15,7 +15,7 @@ #ifndef PLAYER_FUNC_TEST_H #define PLAYER_FUNC_TEST_H -#include "Testplayer.h" +#include "TestPlayer.h" namespace OHOS { namespace Media { diff --git a/multimedia/media/media_cpp_test_standard/player/include/TestPlayer.h b/multimedia/media/media_cpp_test_standard/player/include/TestPlayer.h new file mode 100644 index 0000000000000000000000000000000000000000..9269d8ca0b9fae5cd2287593b22b26ec1f5bf114 --- /dev/null +++ b/multimedia/media/media_cpp_test_standard/player/include/TestPlayer.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PLAYER_TEST_H +#define PLAYER_TEST_H + +#include "securec.h" +#include "TestParamsConfig.h" +#include "window_manager.h" +#include "surface_type.h" +#include "display_type.h" + +namespace OHOS { +namespace Media { +static const std::string SURFACE_STRIDE_ALIGNMENT = "SURFACE_STRIDE_ALIGNMENT"; +static const std::string SURFACE_FORMAT = "SURFACE_FORMAT"; +static WindowConfig g_config = { + 1920, + 1080, + PIXEL_FMT_RGBA_8888, + 0, + 0, + WINDOW_TYPE_NORMAL +}; +static WindowConfig g_sub_config = { + 720, + 480, + PIXEL_FMT_YCRCB_420_SP, + 0, + 0, + WINDOW_TYPE_VIDEO, +}; + +class PlayerSignal { +public: + PlayerStates state_ = PLAYER_IDLE; + int32_t seekPositon_; + bool seekDoneFlag_; + bool mutexFlag_ = true; + std::mutex mutexSeek_; + std::mutex mutexReset_; + std::mutex mutexPrepare_; + std::mutex mutexPlay_; + std::mutex mutexPause_; + std::mutex mutexStop_; + std::condition_variable condVarSeek_; + std::condition_variable condVarReset_; + std::condition_variable condVarPrepare_; + std::condition_variable condVarPlay_; + std::condition_variable condVarPause_; + std::condition_variable condVarStop_; + + void SetState(PlayerStates state); + void SetSeekResult(bool seekDoneFlag); +}; +class TestPlayer { +public: + std::shared_ptr player_ = nullptr; + sptr window_ = nullptr; + explicit TestPlayer(std::shared_ptr test); + virtual ~TestPlayer(); + bool CreatePlayer(); + int32_t SetSource(const std::string &uri); + int32_t SetDataSrc(const std::string &uri, bool seekable); + int32_t Play(); + int32_t Prepare(); + int32_t PrepareAsync(); + int32_t Pause(); + int32_t Stop(); + int32_t Reset(); + int32_t Release(); + int32_t SetVolume(float leftVolume, float rightVolume); + int32_t Seek(int32_t mseconds, PlayerSeekMode mode); + int32_t GetCurrentTime(int32_t ¤tTime); + int32_t GetDuration(int32_t &duration); + int32_t SetPlaybackSpeed(PlaybackRateMode mode); + int32_t GetPlaybackSpeed(PlaybackRateMode &mode); + sptr GetVideoSurface(WindowConfig g_sub_config); + int32_t SetVideoSurface(sptr surface); + bool IsPlaying(); + bool IsLooping(); + int32_t SetLooping(bool loop); + int32_t SetPlayerCallback(const std::shared_ptr &callback); +private: + std::shared_ptr test_; +}; +class TestPlayerCallback : public PlayerCallback { +public: + int errorNum_ = 0; + PlayerStates state_ = PLAYER_STATE_ERROR; + explicit TestPlayerCallback(std::shared_ptr test); + virtual ~TestPlayerCallback(); + void OnError(PlayerErrorType errorType, int32_t errorCode); + int WaitForSeekDone(int32_t currentPositon); + void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody = {}); + int WaitForState(PlayerStates state); +private: + void PrintState(PlayerStates state); + + PlayerErrorType errorType_ = PLAYER_ERROR_UNKNOWN; + int32_t errorCode_ = -1; + bool seekDoneFlag_ = false; + int32_t postion_ = 0; + std::shared_ptr test_; +}; +} +} +#endif \ No newline at end of file diff --git a/multimedia/media/media_cpp_test_standard/player/include/Testplayer.h b/multimedia/media/media_cpp_test_standard/player/include/Testplayer.h index 9269d8ca0b9fae5cd2287593b22b26ec1f5bf114..c7099d4cb9b73c19ae13671386a4e4f25243d715 100755 --- a/multimedia/media/media_cpp_test_standard/player/include/Testplayer.h +++ b/multimedia/media/media_cpp_test_standard/player/include/Testplayer.h @@ -13,108 +13,6 @@ * limitations under the License. */ -#ifndef PLAYER_TEST_H -#define PLAYER_TEST_H - -#include "securec.h" -#include "TestParamsConfig.h" -#include "window_manager.h" -#include "surface_type.h" -#include "display_type.h" - -namespace OHOS { -namespace Media { -static const std::string SURFACE_STRIDE_ALIGNMENT = "SURFACE_STRIDE_ALIGNMENT"; -static const std::string SURFACE_FORMAT = "SURFACE_FORMAT"; -static WindowConfig g_config = { - 1920, - 1080, - PIXEL_FMT_RGBA_8888, - 0, - 0, - WINDOW_TYPE_NORMAL -}; -static WindowConfig g_sub_config = { - 720, - 480, - PIXEL_FMT_YCRCB_420_SP, - 0, - 0, - WINDOW_TYPE_VIDEO, -}; - -class PlayerSignal { -public: - PlayerStates state_ = PLAYER_IDLE; - int32_t seekPositon_; - bool seekDoneFlag_; - bool mutexFlag_ = true; - std::mutex mutexSeek_; - std::mutex mutexReset_; - std::mutex mutexPrepare_; - std::mutex mutexPlay_; - std::mutex mutexPause_; - std::mutex mutexStop_; - std::condition_variable condVarSeek_; - std::condition_variable condVarReset_; - std::condition_variable condVarPrepare_; - std::condition_variable condVarPlay_; - std::condition_variable condVarPause_; - std::condition_variable condVarStop_; - - void SetState(PlayerStates state); - void SetSeekResult(bool seekDoneFlag); -}; -class TestPlayer { -public: - std::shared_ptr player_ = nullptr; - sptr window_ = nullptr; - explicit TestPlayer(std::shared_ptr test); - virtual ~TestPlayer(); - bool CreatePlayer(); - int32_t SetSource(const std::string &uri); - int32_t SetDataSrc(const std::string &uri, bool seekable); - int32_t Play(); - int32_t Prepare(); - int32_t PrepareAsync(); - int32_t Pause(); - int32_t Stop(); - int32_t Reset(); - int32_t Release(); - int32_t SetVolume(float leftVolume, float rightVolume); - int32_t Seek(int32_t mseconds, PlayerSeekMode mode); - int32_t GetCurrentTime(int32_t ¤tTime); - int32_t GetDuration(int32_t &duration); - int32_t SetPlaybackSpeed(PlaybackRateMode mode); - int32_t GetPlaybackSpeed(PlaybackRateMode &mode); - sptr GetVideoSurface(WindowConfig g_sub_config); - int32_t SetVideoSurface(sptr surface); - bool IsPlaying(); - bool IsLooping(); - int32_t SetLooping(bool loop); - int32_t SetPlayerCallback(const std::shared_ptr &callback); -private: - std::shared_ptr test_; -}; -class TestPlayerCallback : public PlayerCallback { -public: - int errorNum_ = 0; - PlayerStates state_ = PLAYER_STATE_ERROR; - explicit TestPlayerCallback(std::shared_ptr test); - virtual ~TestPlayerCallback(); - void OnError(PlayerErrorType errorType, int32_t errorCode); - int WaitForSeekDone(int32_t currentPositon); - void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody = {}); - int WaitForState(PlayerStates state); -private: - void PrintState(PlayerStates state); - - PlayerErrorType errorType_ = PLAYER_ERROR_UNKNOWN; - int32_t errorCode_ = -1; - bool seekDoneFlag_ = false; - int32_t postion_ = 0; - std::shared_ptr test_; -}; -} -} +#ifndef DISABLE_PLAYER_TEST_H +#define DISABLE_PLAYER_TEST_H #endif \ No newline at end of file diff --git a/multimedia/media/media_cpp_test_standard/player/include/common.h b/multimedia/media/media_cpp_test_standard/player/include/common.h index 7eae77d2084f3bd7d67ea96e612310cb94bacc27..158035d056ac0a0f20b51305562e15965f0c967f 100755 --- a/multimedia/media/media_cpp_test_standard/player/include/common.h +++ b/multimedia/media/media_cpp_test_standard/player/include/common.h @@ -12,3 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#ifndef DISABLE_COMMON_TEST_H +#define DISABLE_COMMON_TEST_H +#endif \ No newline at end of file diff --git a/multimedia/media/media_cpp_test_standard/player/src/TestParamsConfig.cpp b/multimedia/media/media_cpp_test_standard/player/src/TestParamsConfig.cpp index 462b802b45c171d2050508d3e634a3375809b1f5..1ff41a3364b6c1fa84287fd9a6c8b66e433b2999 100644 --- a/multimedia/media/media_cpp_test_standard/player/src/TestParamsConfig.cpp +++ b/multimedia/media/media_cpp_test_standard/player/src/TestParamsConfig.cpp @@ -39,9 +39,10 @@ void TestParamsConfig::InitPlayProtocol() { MEDIA_INFO_LOG("%s", __FUNCTION__); char protocol[PARA_MAX_LEN] = "local"; - GetParameter("sys.media.test.play.protocol", "", &protocol[0], PARA_MAX_LEN); + GetParameter("sys.media.test.play.protocol", "local", &protocol[0], PARA_MAX_LEN); if (strcmp(protocol, "local") == 0) { - TestPlayerBasic::TestParamsConfig::GetInstance().SetMountPath("file://data/media"); + TestPlayerBasic::TestParamsConfig::GetInstance().SetMountPath("file://data/media/"); + MEDIA_INFO_LOG("MOUNT_PATH %s", TestPlayerBasic::TestParamsConfig::GetInstance().GetMountPath().c_str()); } } diff --git a/multimedia/media/media_cpp_test_standard/player/src/TestPlayer.cpp b/multimedia/media/media_cpp_test_standard/player/src/TestPlayer.cpp index f2965b99978b654564f5bf61317aee8067ded8cc..562fd8244c49e12ef1d5775681732932e7e6f8fd 100644 --- a/multimedia/media/media_cpp_test_standard/player/src/TestPlayer.cpp +++ b/multimedia/media/media_cpp_test_standard/player/src/TestPlayer.cpp @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "Testplayer.h" +#include "TestPlayer.h" #include "parameter.h" #include "media_errors.h" using namespace OHOS; using namespace OHOS::Media; -TestPlayer::TestPlayer(PlayerSignal *test) +TestPlayer::TestPlayer(std::shared_ptr test) : test_(test) { } @@ -248,7 +248,7 @@ int32_t TestPlayer::SetPlayerCallback(const std::shared_ptr &cal return player_->SetPlayerCallback(callback); } -TestPlayerCallback::TestPlayerCallback(PlayerSignal *test) +TestPlayerCallback::TestPlayerCallback(std::shared_ptr test) : test_(test) { }