${PROJECT_SOURCE_DIR}
)
-SET(UT_SRC
- ut_main.cpp
- player_ut.cpp
- playerTCInfo.hpp
- playerTCWindow.hpp
+FILE(GLOB UT_SRC
+ src/*.cpp
)
ADD_EXECUTABLE(${fw_name} ${UT_SRC})
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_UT_INCLUDE_TC_INFO_H__
+#define __PLAYER_UT_INCLUDE_TC_INFO_H__
+
+#include <iostream>
+#include <vector>
+#include <json/json.h>
+
+namespace playerUTInfo {
+
+struct tcInfos {
+ std::string filePath;
+ int totalDuration = 0;
+
+ struct {
+ int sampleRate = 0;
+ int channels = 0;
+ int bitrate = 0;
+ std::string codecName;
+ } audio;
+
+ struct {
+ int fps = 0;
+ int bitrate = 0;
+ int width = 0;
+ int height = 0;
+ std::string codecName;
+ } video;
+};
+
+std::ostream& operator << (std::ostream &os, const tcInfos &tcInfos_);
+
+class playerTCInfo
+{
+public:
+ explicit playerTCInfo(const std::string dirpath);
+ ~playerTCInfo() = default;
+
+ std::vector<tcInfos> getTCInfos() { return _tcInfos; };
+
+private:
+ Json::Value openConfig();
+ std::vector<tcInfos> parseConfig(Json::Value root);
+ void _printTCInfos();
+
+ std::vector<tcInfos> _tcInfos;
+ std::string _subDirpath;
+};
+
+}
+
+#endif // __PLAYER_UT_INCLUDE_TC_INFO_H__
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_UT_INCLUDE_TC_WINDOW_H__
+#define __PLAYER_UT_INCLUDE_TC_WINDOW_H__
+
+#include <thread>
+
+#include <Elementary.h>
+
+namespace playerUTWindow {
+
+class PlayerTCWindow
+{
+public:
+ ~PlayerTCWindow();
+
+ PlayerTCWindow(const PlayerTCWindow& rhs) = delete;
+ PlayerTCWindow& operator=(const PlayerTCWindow& rhs) = delete;
+
+ static PlayerTCWindow& Instance();
+ static void WindowThread(PlayerTCWindow* tcWindow);
+
+ Evas_Object* getEvasObject() { return _evasObjectWin; }
+
+private:
+ PlayerTCWindow();
+
+ void createWindow_();
+
+ Evas_Object* _evasObjectWin = nullptr;
+ bool _thread_init_done = false;
+ std::thread _thread;
+};
+
+}
+
+#endif // __PLAYER_UT_INCLUDE_TC_WINDOW_H__
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#include <iostream>
-#include <string.h>
-#include <fstream>
-#include <vector>
-#include <json/json.h>
-
-namespace playerUTInfo {
-
-static const std::string tcRootDIR = "/media/USBDriveA1/";
-static const std::string tcInfoFileName = "contentsInfo.config";
-
-class playerTCInfo;
-
-struct tcInfos {
- std::string filePath;
- int totalDuration = 0;
-
- struct {
- int sampleRate = 0;
- int channels = 0;
- int bitrate = 0;
- std::string codecName;
- } audio;
-
- struct {
- int fps = 0;
- int bitrate = 0;
- int width = 0;
- int height = 0;
- std::string codecName;
- } video;
-};
-
-std::ostream& operator << (std::ostream &os, const tcInfos &tcInfos_) {
- return (os << tcInfos_.filePath);
-}
-
-class playerTCInfo
-{
-private:
- std::vector<tcInfos> _tcInfos;
- std::string _subDirpath;
-
- Json::Value openConfig();
- std::vector<tcInfos> parseConfig(Json::Value root);
- void _printTCInfos();
-
-public:
- explicit playerTCInfo(const std::string dirpath);
- ~playerTCInfo() = default;
-
- std::vector<tcInfos> getTCInfos() { return _tcInfos; };
-};
-
-playerTCInfo::playerTCInfo(const std::string dirpath)
-{
- _subDirpath = dirpath;
- _tcInfos = parseConfig(openConfig());
- _printTCInfos();
-}
-
-Json::Value playerTCInfo::openConfig()
-{
- std::string configFilePath = tcRootDIR + _subDirpath + "/" + tcInfoFileName;
- std::ifstream jsonFile(configFilePath, std::ifstream::binary);
-
- Json::Value root;
- jsonFile >> root;
-
- jsonFile.close();
-
- return root;
-
-}
-
-std::vector<tcInfos> playerTCInfo::parseConfig(Json::Value root)
-{
- Json::Value& contents = root["contents"];
-
- std::vector<tcInfos> infos;
-
- for (auto& content : contents) {
- Json::Value& audio = content["audio"];
- Json::Value& video = content["video"];
-
- tcInfos info {
- .filePath = tcRootDIR + _subDirpath + "/" + content["path"].asString(),
- .totalDuration = content["duration"].asInt(),
-
- .audio = {
- .sampleRate = audio["samplerate"].asInt(),
- .channels = audio["channels"].asInt(),
- .bitrate = audio["bitrate"].asInt(),
- .codecName = audio["codec"].asString(),
- },
-
- .video = {
- .fps = video["FPS"].asInt(),
- .bitrate = video["bitrate"].asInt(),
- .width = video["width"].asInt(),
- .height = video["height"].asInt(),
- .codecName = video["codec"].asString(),
- }
- };
-
- infos.push_back(info);
- }
-
- return infos;
-}
-
-void playerTCInfo::_printTCInfos()
-{
- for (auto tcinfo : _tcInfos) {
- std::cout << "filePath: " << tcinfo.filePath << std::endl;
- std::cout << "totalDuration: " << tcinfo.totalDuration << std::endl;
- std::cout << "audioSampleRate: " << tcinfo.audio.sampleRate << std::endl;
- std::cout << "audioChannels: " << tcinfo.audio.channels << std::endl;
- std::cout << "audioBitrate: " << tcinfo.audio.bitrate << std::endl;
- std::cout << "audioCodecName: " << tcinfo.audio.codecName << std::endl;
- std::cout << "videoFPS: " << tcinfo.video.fps << std::endl;
- std::cout << "videoBitrate: " << tcinfo.video.bitrate << std::endl;
- std::cout << "videoWidth: " << tcinfo.video.width << std::endl;
- std::cout << "videoHeight: " << tcinfo.video.height << std::endl;
- std::cout << "videoCodecName: " << tcinfo.video.codecName << std::endl << std::endl;
- }
-}
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#include <cassert>
-#include <chrono>
-#include <thread>
-
-#include <Elementary.h>
-
-#define PACKAGE_NAME "player_ut"
-
-namespace playerUTInfo {
-
-namespace {
-class PlayerTCWindow;
-
-static std::unique_ptr<PlayerTCWindow> ptr;
-
-class PlayerTCWindow
-{
-public:
- ~PlayerTCWindow();
-
- PlayerTCWindow(const PlayerTCWindow& rhs) = delete;
- PlayerTCWindow& operator=(const PlayerTCWindow& rhs) = delete;
-
- static PlayerTCWindow& Instance();
- static void WindowThread(PlayerTCWindow* tcWindow);
-
- Evas_Object* getEvasObject() { return _evasObjectWin; }
-
-private:
- PlayerTCWindow();
-
- void createWindow_();
-
- Evas_Object* _evasObjectWin = nullptr;
- bool thread_init_done_ = false;
- std::thread thread_;
-};
-
-PlayerTCWindow& PlayerTCWindow::Instance() {
- if (!ptr.get()) ptr.reset(new PlayerTCWindow());
- return *(ptr.get());
-}
-
-PlayerTCWindow::PlayerTCWindow() {
- thread_ = std::thread(PlayerTCWindow::WindowThread, this);
- while (!thread_init_done_) {
- std::this_thread::sleep_for(std::chrono::milliseconds(1));
- }
- std::cout << "PlayerTCWindow()" << std::endl;
-}
-
-PlayerTCWindow::~PlayerTCWindow() {
- ecore_thread_main_loop_begin();
- elm_exit();
- ecore_thread_main_loop_end();
- thread_.join();
- std::cout << "~PlayerTCWindow()" << std::endl;
-}
-
-void PlayerTCWindow::WindowThread(PlayerTCWindow* tcWindow) {
- elm_init(1, NULL);
- tcWindow->createWindow_();
- tcWindow->thread_init_done_ = true;
- elm_run();
- elm_shutdown();
-}
-
-void PlayerTCWindow::createWindow_() {
- int w = 0;
- int h = 0;
-
- ecore_thread_main_loop_begin();
-
- _evasObjectWin = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_BASIC);
- assert(_evasObjectWin);
-
- elm_win_title_set(_evasObjectWin, PACKAGE_NAME);
- elm_win_autodel_set(_evasObjectWin, EINA_TRUE);
- elm_win_aux_hint_add(_evasObjectWin, "wm.policy.win.user.geometry", "1");
-
- elm_win_screen_size_get(_evasObjectWin, NULL, NULL, &w, &h);
- std::cout << "width, height: " << w << ", " << h << std::endl;
- evas_object_move(_evasObjectWin, 0, 0);
- evas_object_resize(_evasObjectWin, w, h);
- evas_object_show(_evasObjectWin);
-
- ecore_thread_main_loop_end();
-
- std::cout << "Window [" << _evasObjectWin << "]" << std::endl;
-}
-
-}
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#include <stdio.h>
-#include <chrono>
-#include <thread>
-#include <iostream>
-
-#include "gtest/gtest.h"
-
-#include "player.h"
-#include "player_internal.h"
-#include "unittest/playerTCInfo.hpp"
-#include "unittest/playerTCWindow.hpp"
-
-using namespace playerUTInfo;
-
-class PlayerContentsTest : public ::testing::TestWithParam<tcInfos> {
-public:
- PlayerContentsTest() : tcWindow_(PlayerTCWindow::Instance()) { }
-
- virtual void SetUp() override {
- ASSERT_EQ(player_create(&_player), PLAYER_ERROR_NONE);
-
- std::cout << "SetUp()" << std::endl;
- }
-
- virtual void TearDown() override {
- ASSERT_EQ(player_destroy(_player), PLAYER_ERROR_NONE);
-
- std::cout << "TearDown()" << std::endl;
- }
-
- int TestSetPlayPosition(int milliseconds, bool accurate) {
- _seek_done = false;
- return player_set_play_position(_player, milliseconds, accurate, seek_completed_cb, this);
- }
-
- static void seek_completed_cb(void *user_data) {
- auto test_ = static_cast<PlayerContentsTest*>(user_data);
- std::unique_lock<std::mutex> lk(test_->_seek_done_m);
- test_->_seek_done = true;
- std::cout << "seek_completed_cb()" << std::endl;
- lk.unlock();
- test_->_seek_done_cv.notify_all();
- }
-
- bool WaitForSeek() {
- std::unique_lock<std::mutex> lk(_seek_done_m);
- std::cout << "WaitForSeek start" << std::endl;
- if (!_seek_done) {
- _seek_done_cv.wait_for(lk, std::chrono::seconds(10),
- [this]() -> bool { return _seek_done; });
- }
- std::cout << "WaitForSeek stop" << std::endl;
- return _seek_done;
- }
-
-public:
- player_h _player {};
- PlayerTCWindow& tcWindow_;
-
-private:
- std::mutex _seek_done_m;
- std::condition_variable _seek_done_cv;
- bool _seek_done = true;
-};
-
-TEST_P(PlayerContentsTest, contents_test_p) {
- int duration = 0;
- int sample_rate = 0;
- int channel = 0;
- int bit_rate = 0;
- int fps = 0;
- int v_bit_rate = 0;
- char *audio_codec = NULL;
- char *video_codec = NULL;
- int w = 0;
- int h = 0;
-
- tcInfos _tcInfos = GetParam();
- std::cout << "dir: " << _tcInfos << std::endl;
-
- ecore_thread_main_loop_begin();
- ASSERT_EQ(player_set_display(_player, PLAYER_DISPLAY_TYPE_OVERLAY, tcWindow_.getEvasObject()), PLAYER_ERROR_NONE);
- ecore_thread_main_loop_end();
-
- ASSERT_EQ(player_set_uri(_player, _tcInfos.filePath.c_str()), PLAYER_ERROR_NONE);
- ASSERT_EQ(player_prepare(_player), PLAYER_ERROR_NONE);
-
- EXPECT_EQ(player_get_duration(_player, &duration), PLAYER_ERROR_NONE);
- EXPECT_EQ(duration, _tcInfos.totalDuration);
-
- EXPECT_EQ(player_get_audio_stream_info(_player, &sample_rate, &channel, &bit_rate), PLAYER_ERROR_NONE);
- EXPECT_EQ(sample_rate, _tcInfos.audio.sampleRate);
- EXPECT_EQ(channel, _tcInfos.audio.channels);
- EXPECT_EQ(bit_rate, _tcInfos.audio.bitrate);
-
- EXPECT_EQ(player_get_video_stream_info(_player, &fps, &v_bit_rate), PLAYER_ERROR_NONE);
- EXPECT_EQ(fps, _tcInfos.video.fps);
- EXPECT_EQ(v_bit_rate, _tcInfos.video.bitrate);
-
- EXPECT_EQ(player_get_video_size(_player, &w, &h), PLAYER_ERROR_NONE);
- EXPECT_EQ(w, _tcInfos.video.width);
- EXPECT_EQ(h, _tcInfos.video.height);
-
- EXPECT_EQ(player_get_codec_info(_player, &audio_codec, &video_codec), PLAYER_ERROR_NONE);
- std::string audioCodecName = audio_codec;
- EXPECT_NE(audioCodecName.find(_tcInfos.audio.codecName), std::string::npos);
- if (audio_codec)
- free(audio_codec);
-
- std::string videoCodecName = video_codec;
- EXPECT_NE(videoCodecName.find(_tcInfos.video.codecName), std::string::npos);
- if (video_codec)
- free(video_codec);
-
- EXPECT_EQ(player_start(_player), PLAYER_ERROR_NONE);
- std::this_thread::sleep_for(std::chrono::seconds(1));
-
- std::cout << "playback rate 0.5" << std::endl;
- EXPECT_EQ(player_set_playback_rate(_player, 0.5), PLAYER_ERROR_NONE);
-
- std::cout << "playback rate 2.0" << std::endl;
- EXPECT_EQ(player_set_playback_rate(_player, 2.0), PLAYER_ERROR_NONE);
-
- std::cout << "playback rate 1.0" << std::endl;
- EXPECT_EQ(player_set_playback_rate(_player, 1.0), PLAYER_ERROR_NONE);
-
- std::cout << "seek to " << duration / 4 << " with accurate 0" << std::endl;
- int ret = TestSetPlayPosition(duration / 4, 0);
- EXPECT_EQ(ret, PLAYER_ERROR_NONE);
- if (ret == PLAYER_ERROR_NONE) {
- EXPECT_TRUE(WaitForSeek());
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
-
- std::cout << "seek to " << duration / 2 << " with accurate 1" << std::endl;
- ret = TestSetPlayPosition(duration / 2, 1);
- EXPECT_EQ(ret, PLAYER_ERROR_NONE);
- if (ret == PLAYER_ERROR_NONE) {
- EXPECT_TRUE(WaitForSeek());
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
-
- EXPECT_EQ(player_stop(_player), PLAYER_ERROR_NONE);
- EXPECT_EQ(player_unprepare(_player), PLAYER_ERROR_NONE);
-}
-
-TEST_P(PlayerContentsTest, DISABLED_visual_verify_contents_test_p) {
- int duration = 0;
- int sample_rate = 0;
- int channel = 0;
- int bit_rate = 0;
- int fps = 0;
- int v_bit_rate = 0;
- char *audio_codec = NULL;
- char *video_codec = NULL;
- int w = 0;
- int h = 0;
-
- tcInfos _tcInfos = GetParam();
- std::cout << "dir: " << _tcInfos << std::endl;
-
- ecore_thread_main_loop_begin();
- ASSERT_EQ(player_set_display(_player, PLAYER_DISPLAY_TYPE_OVERLAY, tcWindow_.getEvasObject()), PLAYER_ERROR_NONE);
- ecore_thread_main_loop_end();
-
- ASSERT_EQ(player_set_uri(_player, _tcInfos.filePath.c_str()), PLAYER_ERROR_NONE);
- ASSERT_EQ(player_prepare(_player), PLAYER_ERROR_NONE);
-
- EXPECT_EQ(player_get_duration(_player, &duration), PLAYER_ERROR_NONE);
- EXPECT_EQ(duration, _tcInfos.totalDuration);
-
- EXPECT_EQ(player_get_audio_stream_info(_player, &sample_rate, &channel, &bit_rate), PLAYER_ERROR_NONE);
- EXPECT_EQ(sample_rate, _tcInfos.audio.sampleRate);
- EXPECT_EQ(channel, _tcInfos.audio.channels);
- EXPECT_EQ(bit_rate, _tcInfos.audio.bitrate);
-
- EXPECT_EQ(player_get_video_stream_info(_player, &fps, &v_bit_rate), PLAYER_ERROR_NONE);
- EXPECT_EQ(fps, _tcInfos.video.fps);
- EXPECT_EQ(v_bit_rate, _tcInfos.video.bitrate);
-
- EXPECT_EQ(player_get_video_size(_player, &w, &h), PLAYER_ERROR_NONE);
- EXPECT_EQ(w, _tcInfos.video.width);
- EXPECT_EQ(h, _tcInfos.video.height);
-
- EXPECT_EQ(player_get_codec_info(_player, &audio_codec, &video_codec), PLAYER_ERROR_NONE);
- std::string audioCodecName = audio_codec;
- EXPECT_NE(audioCodecName.find(_tcInfos.audio.codecName), std::string::npos);
- if (audio_codec)
- free(audio_codec);
-
- std::string videoCodecName = video_codec;
- EXPECT_NE(videoCodecName.find(_tcInfos.video.codecName), std::string::npos);
- if (video_codec)
- free(video_codec);
-
- EXPECT_EQ(player_start(_player), PLAYER_ERROR_NONE);
- std::this_thread::sleep_for(std::chrono::seconds(3));
-
- std::cout << "playback rate 0.5" << std::endl;
- EXPECT_EQ(player_set_playback_rate(_player, 0.5), PLAYER_ERROR_NONE);
- std::this_thread::sleep_for(std::chrono::seconds(2));
-
- std::cout << "playback rate 2.0" << std::endl;
- EXPECT_EQ(player_set_playback_rate(_player, 2.0), PLAYER_ERROR_NONE);
- std::this_thread::sleep_for(std::chrono::seconds(2));
-
- std::cout << "playback rate 1.0" << std::endl;
- EXPECT_EQ(player_set_playback_rate(_player, 1.0), PLAYER_ERROR_NONE);
- std::this_thread::sleep_for(std::chrono::seconds(2));
-
- std::cout << "seek to " << duration / 4 << " with accurate 0" << std::endl;
- int ret = TestSetPlayPosition(duration / 4, 0);
- EXPECT_EQ(ret, PLAYER_ERROR_NONE);
- if (ret == PLAYER_ERROR_NONE) {
- EXPECT_TRUE(WaitForSeek());
- }
- std::this_thread::sleep_for(std::chrono::seconds(3));
-
- std::cout << "seek to " << duration / 2 << " with accurate 1" << std::endl;
- ret = TestSetPlayPosition(duration / 2, 1);
- EXPECT_EQ(ret, PLAYER_ERROR_NONE);
- if (ret == PLAYER_ERROR_NONE) {
- EXPECT_TRUE(WaitForSeek());
- }
- std::this_thread::sleep_for(std::chrono::seconds(3));
-
- EXPECT_EQ(player_stop(_player), PLAYER_ERROR_NONE);
- EXPECT_EQ(player_unprepare(_player), PLAYER_ERROR_NONE);
-}
-
-INSTANTIATE_TEST_SUITE_P(PlayerContentsTestFull, PlayerContentsTest,
- ::testing::ValuesIn(playerTCInfo("TestContents").getTCInfos())
-);
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2022 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <json/json.h>
+
+#include "unittest/include/playerTCInfo.hpp"
+
+namespace playerUTInfo {
+
+static const std::string tcRootDIR = "/media/USBDriveA1/";
+static const std::string tcInfoFileName = "contentsInfo.config";
+
+std::ostream& operator << (std::ostream &os, const tcInfos &tcInfos_) {
+ return (os << tcInfos_.filePath);
+}
+
+playerTCInfo::playerTCInfo(const std::string dirpath)
+{
+ _subDirpath = dirpath;
+ _tcInfos = parseConfig(openConfig());
+ _printTCInfos();
+}
+
+Json::Value playerTCInfo::openConfig()
+{
+ std::string configFilePath = tcRootDIR + _subDirpath + "/" + tcInfoFileName;
+ std::ifstream jsonFile(configFilePath, std::ifstream::binary);
+
+ Json::Value root;
+ jsonFile >> root;
+
+ jsonFile.close();
+
+ return root;
+}
+
+std::vector<tcInfos> playerTCInfo::parseConfig(Json::Value root)
+{
+ Json::Value& contents = root["contents"];
+
+ std::vector<tcInfos> infos;
+
+ for (auto& content : contents) {
+ Json::Value& audio = content["audio"];
+ Json::Value& video = content["video"];
+
+ tcInfos info {
+ .filePath = tcRootDIR + _subDirpath + "/" + content["path"].asString(),
+ .totalDuration = content["duration"].asInt(),
+
+ .audio = {
+ .sampleRate = audio["samplerate"].asInt(),
+ .channels = audio["channels"].asInt(),
+ .bitrate = audio["bitrate"].asInt(),
+ .codecName = audio["codec"].asString(),
+ },
+
+ .video = {
+ .fps = video["FPS"].asInt(),
+ .bitrate = video["bitrate"].asInt(),
+ .width = video["width"].asInt(),
+ .height = video["height"].asInt(),
+ .codecName = video["codec"].asString(),
+ }
+ };
+
+ infos.push_back(info);
+ }
+
+ return infos;
+}
+
+void playerTCInfo::_printTCInfos()
+{
+ for (auto tcinfo : _tcInfos) {
+ std::cout << "filePath: " << tcinfo.filePath << std::endl;
+ std::cout << "totalDuration: " << tcinfo.totalDuration << std::endl;
+ std::cout << "audioSampleRate: " << tcinfo.audio.sampleRate << std::endl;
+ std::cout << "audioChannels: " << tcinfo.audio.channels << std::endl;
+ std::cout << "audioBitrate: " << tcinfo.audio.bitrate << std::endl;
+ std::cout << "audioCodecName: " << tcinfo.audio.codecName << std::endl;
+ std::cout << "videoFPS: " << tcinfo.video.fps << std::endl;
+ std::cout << "videoBitrate: " << tcinfo.video.bitrate << std::endl;
+ std::cout << "videoWidth: " << tcinfo.video.width << std::endl;
+ std::cout << "videoHeight: " << tcinfo.video.height << std::endl;
+ std::cout << "videoCodecName: " << tcinfo.video.codecName << std::endl << std::endl;
+ }
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <iostream>
+#include <cassert>
+#include <chrono>
+#include <thread>
+
+#include <Elementary.h>
+#include "unittest/include/playerTCWindow.hpp"
+
+#define PACKAGE_NAME "player_ut"
+
+namespace playerUTWindow {
+
+static std::unique_ptr<PlayerTCWindow> ptr;
+
+PlayerTCWindow& PlayerTCWindow::Instance() {
+ if (!ptr.get()) ptr.reset(new PlayerTCWindow());
+ return *(ptr.get());
+}
+
+PlayerTCWindow::PlayerTCWindow() {
+ _thread = std::thread(PlayerTCWindow::WindowThread, this);
+ while (!_thread_init_done) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
+ }
+ std::cout << "PlayerTCWindow()" << std::endl;
+}
+
+PlayerTCWindow::~PlayerTCWindow() {
+ ecore_thread_main_loop_begin();
+ elm_exit();
+ ecore_thread_main_loop_end();
+ _thread.join();
+ std::cout << "~PlayerTCWindow()" << std::endl;
+}
+
+void PlayerTCWindow::WindowThread(PlayerTCWindow* tcWindow) {
+ elm_init(1, NULL);
+ tcWindow->createWindow_();
+ tcWindow->_thread_init_done = true;
+ elm_run();
+ elm_shutdown();
+}
+
+void PlayerTCWindow::createWindow_() {
+ int w = 0;
+ int h = 0;
+
+ ecore_thread_main_loop_begin();
+
+ _evasObjectWin = elm_win_add(NULL, PACKAGE_NAME, ELM_WIN_BASIC);
+ assert(_evasObjectWin);
+
+ elm_win_title_set(_evasObjectWin, PACKAGE_NAME);
+ elm_win_autodel_set(_evasObjectWin, EINA_TRUE);
+ elm_win_aux_hint_add(_evasObjectWin, "wm.policy.win.user.geometry", "1");
+
+ elm_win_screen_size_get(_evasObjectWin, NULL, NULL, &w, &h);
+ std::cout << "width, height: " << w << ", " << h << std::endl;
+ evas_object_move(_evasObjectWin, 0, 0);
+ evas_object_resize(_evasObjectWin, w, h);
+ evas_object_show(_evasObjectWin);
+
+ ecore_thread_main_loop_end();
+
+ std::cout << "Window [" << _evasObjectWin << "]" << std::endl;
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <chrono>
+#include <thread>
+#include <iostream>
+
+#include "gtest/gtest.h"
+
+#include "player.h"
+#include "player_internal.h"
+#include "unittest/include/playerTCInfo.hpp"
+#include "unittest/include/playerTCWindow.hpp"
+
+using namespace playerUTInfo;
+using namespace playerUTWindow;
+
+class PlayerContentsTest : public ::testing::TestWithParam<tcInfos> {
+public:
+ PlayerContentsTest() : _tcWindow(PlayerTCWindow::Instance()) { }
+
+ virtual void SetUp() override {
+ ASSERT_EQ(player_create(&_player), PLAYER_ERROR_NONE);
+
+ std::cout << "SetUp()" << std::endl;
+ }
+
+ virtual void TearDown() override {
+ ASSERT_EQ(player_destroy(_player), PLAYER_ERROR_NONE);
+
+ std::cout << "TearDown()" << std::endl;
+ }
+
+public:
+ player_h _player {};
+ PlayerTCWindow& _tcWindow;
+};
+
+TEST_P(PlayerContentsTest, player_contents_test_p) {
+ int duration = 0;
+ int sample_rate = 0;
+ int channel = 0;
+ int bit_rate = 0;
+ int fps = 0;
+ int v_bit_rate = 0;
+ char *audio_codec = NULL;
+ char *video_codec = NULL;
+ int w = 0;
+ int h = 0;
+
+ tcInfos _tcInfos = GetParam();
+ std::cout << "dir: " << _tcInfos << std::endl;
+
+ ecore_thread_main_loop_begin();
+ ASSERT_EQ(player_set_display(_player, PLAYER_DISPLAY_TYPE_OVERLAY, _tcWindow.getEvasObject()), PLAYER_ERROR_NONE);
+ ecore_thread_main_loop_end();
+
+ ASSERT_EQ(player_set_uri(_player, _tcInfos.filePath.c_str()), PLAYER_ERROR_NONE);
+ ASSERT_EQ(player_prepare(_player), PLAYER_ERROR_NONE);
+
+ EXPECT_EQ(player_get_duration(_player, &duration), PLAYER_ERROR_NONE);
+ EXPECT_EQ(duration, _tcInfos.totalDuration);
+
+ EXPECT_EQ(player_get_audio_stream_info(_player, &sample_rate, &channel, &bit_rate), PLAYER_ERROR_NONE);
+ EXPECT_EQ(sample_rate, _tcInfos.audio.sampleRate);
+ EXPECT_EQ(channel, _tcInfos.audio.channels);
+ EXPECT_EQ(bit_rate, _tcInfos.audio.bitrate);
+
+ EXPECT_EQ(player_get_video_stream_info(_player, &fps, &v_bit_rate), PLAYER_ERROR_NONE);
+ EXPECT_EQ(fps, _tcInfos.video.fps);
+ EXPECT_EQ(v_bit_rate, _tcInfos.video.bitrate);
+
+ EXPECT_EQ(player_get_video_size(_player, &w, &h), PLAYER_ERROR_NONE);
+ EXPECT_EQ(w, _tcInfos.video.width);
+ EXPECT_EQ(h, _tcInfos.video.height);
+
+ EXPECT_EQ(player_get_codec_info(_player, &audio_codec, &video_codec), PLAYER_ERROR_NONE);
+ std::string audioCodecName = audio_codec;
+ EXPECT_NE(audioCodecName.find(_tcInfos.audio.codecName), std::string::npos);
+ if (audio_codec)
+ free(audio_codec);
+
+ std::string videoCodecName = video_codec;
+ EXPECT_NE(videoCodecName.find(_tcInfos.video.codecName), std::string::npos);
+ if (video_codec)
+ free(video_codec);
+
+ EXPECT_EQ(player_start(_player), PLAYER_ERROR_NONE);
+ std::this_thread::sleep_for(std::chrono::milliseconds(500));
+
+ EXPECT_EQ(player_stop(_player), PLAYER_ERROR_NONE);
+ EXPECT_EQ(player_unprepare(_player), PLAYER_ERROR_NONE);
+}
+
+TEST_P(PlayerContentsTest, DISABLED_human_verify_player_contents_test_p) {
+ int duration = 0;
+ int sample_rate = 0;
+ int channel = 0;
+ int bit_rate = 0;
+ int fps = 0;
+ int v_bit_rate = 0;
+ char *audio_codec = NULL;
+ char *video_codec = NULL;
+ int w = 0;
+ int h = 0;
+
+ tcInfos _tcInfos = GetParam();
+ std::cout << "dir: " << _tcInfos << std::endl;
+
+ ecore_thread_main_loop_begin();
+ ASSERT_EQ(player_set_display(_player, PLAYER_DISPLAY_TYPE_OVERLAY, _tcWindow.getEvasObject()), PLAYER_ERROR_NONE);
+ ecore_thread_main_loop_end();
+
+ ASSERT_EQ(player_set_uri(_player, _tcInfos.filePath.c_str()), PLAYER_ERROR_NONE);
+ ASSERT_EQ(player_prepare(_player), PLAYER_ERROR_NONE);
+
+ EXPECT_EQ(player_get_duration(_player, &duration), PLAYER_ERROR_NONE);
+ EXPECT_EQ(duration, _tcInfos.totalDuration);
+
+ EXPECT_EQ(player_get_audio_stream_info(_player, &sample_rate, &channel, &bit_rate), PLAYER_ERROR_NONE);
+ EXPECT_EQ(sample_rate, _tcInfos.audio.sampleRate);
+ EXPECT_EQ(channel, _tcInfos.audio.channels);
+ EXPECT_EQ(bit_rate, _tcInfos.audio.bitrate);
+
+ EXPECT_EQ(player_get_video_stream_info(_player, &fps, &v_bit_rate), PLAYER_ERROR_NONE);
+ EXPECT_EQ(fps, _tcInfos.video.fps);
+ EXPECT_EQ(v_bit_rate, _tcInfos.video.bitrate);
+
+ EXPECT_EQ(player_get_video_size(_player, &w, &h), PLAYER_ERROR_NONE);
+ EXPECT_EQ(w, _tcInfos.video.width);
+ EXPECT_EQ(h, _tcInfos.video.height);
+
+ EXPECT_EQ(player_get_codec_info(_player, &audio_codec, &video_codec), PLAYER_ERROR_NONE);
+ std::string audioCodecName = audio_codec;
+ EXPECT_NE(audioCodecName.find(_tcInfos.audio.codecName), std::string::npos);
+ if (audio_codec)
+ free(audio_codec);
+
+ std::string videoCodecName = video_codec;
+ EXPECT_NE(videoCodecName.find(_tcInfos.video.codecName), std::string::npos);
+ if (video_codec)
+ free(video_codec);
+
+ EXPECT_EQ(player_start(_player), PLAYER_ERROR_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+
+ EXPECT_EQ(player_stop(_player), PLAYER_ERROR_NONE);
+ EXPECT_EQ(player_unprepare(_player), PLAYER_ERROR_NONE);
+}
+
+INSTANTIATE_TEST_SUITE_P(PlayerContentsTestFull, PlayerContentsTest,
+ ::testing::ValuesIn(playerTCInfo("TestContents").getTCInfos())
+);
--- /dev/null
+/*
+ * Copyright (c) 2022 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <chrono>
+#include <thread>
+#include <iostream>
+
+#include "gtest/gtest.h"
+
+#include "player.h"
+#include "player_internal.h"
+#include "unittest/include/playerTCInfo.hpp"
+#include "unittest/include/playerTCWindow.hpp"
+
+using namespace playerUTInfo;
+using namespace playerUTWindow;
+
+class PlayerFeaturesTest : public ::testing::TestWithParam<tcInfos> {
+public:
+ PlayerFeaturesTest() : _tcWindow(PlayerTCWindow::Instance()) { }
+
+ virtual void SetUp() override {
+ ASSERT_EQ(player_create(&_player), PLAYER_ERROR_NONE);
+
+ std::cout << "SetUp()" << std::endl;
+ }
+
+ virtual void TearDown() override {
+ ASSERT_EQ(player_destroy(_player), PLAYER_ERROR_NONE);
+
+ std::cout << "TearDown()" << std::endl;
+ }
+
+ int TestSetPlayPosition(int milliseconds, bool accurate) {
+ _seek_done = false;
+ return player_set_play_position(_player, milliseconds, accurate, seek_completed_cb, this);
+ }
+
+ static void seek_completed_cb(void *user_data) {
+ auto test_ = static_cast<PlayerFeaturesTest*>(user_data);
+ std::unique_lock<std::mutex> lk(test_->_seek_done_m);
+ test_->_seek_done = true;
+ std::cout << "seek_completed_cb()" << std::endl;
+ lk.unlock();
+ test_->_seek_done_cv.notify_all();
+ }
+
+ bool WaitForSeek() {
+ std::unique_lock<std::mutex> lk(_seek_done_m);
+ std::cout << "WaitForSeek start" << std::endl;
+ if (!_seek_done) {
+ _seek_done_cv.wait_for(lk, std::chrono::seconds(10),
+ [this]() -> bool { return _seek_done; });
+ }
+ std::cout << "WaitForSeek stop" << std::endl;
+ return _seek_done;
+ }
+
+public:
+ player_h _player {};
+ PlayerTCWindow& _tcWindow;
+
+private:
+ std::mutex _seek_done_m;
+ std::condition_variable _seek_done_cv;
+ bool _seek_done = true;
+};
+
+TEST_P(PlayerFeaturesTest, player_features_test_p) {
+ int duration = 0;
+
+ tcInfos _tcInfos = GetParam();
+ std::cout << "dir: " << _tcInfos << std::endl;
+
+ ecore_thread_main_loop_begin();
+ ASSERT_EQ(player_set_display(_player, PLAYER_DISPLAY_TYPE_OVERLAY, _tcWindow.getEvasObject()), PLAYER_ERROR_NONE);
+ ecore_thread_main_loop_end();
+
+ ASSERT_EQ(player_set_uri(_player, _tcInfos.filePath.c_str()), PLAYER_ERROR_NONE);
+ ASSERT_EQ(player_prepare(_player), PLAYER_ERROR_NONE);
+
+ EXPECT_EQ(player_get_duration(_player, &duration), PLAYER_ERROR_NONE);
+
+ EXPECT_EQ(player_start(_player), PLAYER_ERROR_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ std::cout << "playback rate 0.5" << std::endl;
+ EXPECT_EQ(player_set_playback_rate(_player, 0.5), PLAYER_ERROR_NONE);
+
+ std::cout << "playback rate 2.0" << std::endl;
+ EXPECT_EQ(player_set_playback_rate(_player, 2.0), PLAYER_ERROR_NONE);
+
+ std::cout << "playback rate 1.0" << std::endl;
+ EXPECT_EQ(player_set_playback_rate(_player, 1.0), PLAYER_ERROR_NONE);
+
+ std::cout << "seek to " << duration / 4 << " with accurate 0" << std::endl;
+ int ret = TestSetPlayPosition(duration / 4, 0);
+ EXPECT_EQ(ret, PLAYER_ERROR_NONE);
+ if (ret == PLAYER_ERROR_NONE) {
+ EXPECT_TRUE(WaitForSeek());
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+
+ std::cout << "seek to " << duration / 2 << " with accurate 1" << std::endl;
+ ret = TestSetPlayPosition(duration / 2, 1);
+ EXPECT_EQ(ret, PLAYER_ERROR_NONE);
+ if (ret == PLAYER_ERROR_NONE) {
+ EXPECT_TRUE(WaitForSeek());
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+
+ EXPECT_EQ(player_stop(_player), PLAYER_ERROR_NONE);
+ EXPECT_EQ(player_unprepare(_player), PLAYER_ERROR_NONE);
+}
+
+INSTANTIATE_TEST_SUITE_P(PlayerFeaturesTestFull, PlayerFeaturesTest,
+ ::testing::ValuesIn(playerTCInfo("TestContents/Features").getTCInfos())
+);
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include "gtest/gtest.h"
+
+int main(int argc, char *argv[])
+{
+ try {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+ } catch (const std::exception &e) {
+ std::cout << "caught exception: " << e.what() << std::endl;
+ return -1;
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#include "gtest/gtest.h"
-
-int main(int argc, char *argv[])
-{
- try {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
- } catch (const std::exception &e) {
- std::cout << "caught exception: " << e.what() << std::endl;
- return -1;
- }
-}