NAL_PREFIX_SVC = 14
} nal_unit_type;
-#define ES_DEFAULT_VIDEO_PTS_OFFSET 42
-#define ES_DEFAULT_VIDEO_FPS 24
+#define ES_DEFAULT_VIDEO_PTS_OFFSET_MS 42
+#define ES_DEFAULT_VIDEO_PTS_OFFSET_US ES_DEFAULT_VIDEO_PTS_OFFSET_MS * 1000
+#define ES_DEFAULT_VIDEO_FPS 24
-#define ES_DEFAULT_AUDIO_PTS_OFFSET 23
+#define ES_DEFAULT_AUDIO_PTS_OFFSET_MS 23
+#define ES_DEFAULT_AUDIO_PTS_OFFSET_US ES_DEFAULT_AUDIO_PTS_OFFSET_MS * 1000
static const std::string tc_root_dir = "/home/owner/";
class EsStreamReader {
public:
- explicit EsStreamReader(const std::string dirpath,
- esplusplayer_stream_type type) {
+ EsStreamReader(const std::string dirpath,
+ esplusplayer_stream_type type,
+ esplusplayer_time_unit_type timeunit = ESPLUSPLAYER_TIME_UNIT_MS)
+ : ES_DEFAULT_VIDEO_PTS_OFFSET(timeunit == ESPLUSPLAYER_TIME_UNIT_MS ?
+ ES_DEFAULT_VIDEO_PTS_OFFSET_MS : ES_DEFAULT_VIDEO_PTS_OFFSET_US),
+ ES_DEFAULT_AUDIO_PTS_OFFSET(timeunit == ESPLUSPLAYER_TIME_UNIT_MS ?
+ ES_DEFAULT_AUDIO_PTS_OFFSET_MS : ES_DEFAULT_AUDIO_PTS_OFFSET_US) {
dir_path_ = tc_root_dir + dirpath;
es_data_file_ = dir_path_ + "ESP.es";
es_info_file_ = dir_path_ + "ESP.info";
}
bool ReadNextPacket(esplusplayer_es_packet& pkt) {
- static guint64 pts = 0L;
if (!stream_.is_open()) {
stream_ = std::ifstream(es_data_file_, std::ifstream::binary);
if (!stream_.is_open()) return false;
memcpy(pkt.buffer, tmp, size);
pkt.pts = pts;
- pkt.duration = ES_DEFAULT_VIDEO_PTS_OFFSET;
+ pkt.duration = ES_DEFAULT_AUDIO_PTS_OFFSET;
pkt.buffer_size = size;
- pts += ES_DEFAULT_VIDEO_PTS_OFFSET;
+ pts += ES_DEFAULT_AUDIO_PTS_OFFSET;
}
delete[] tmp;
return true;
std::string extra_codec_file_;
std::ifstream stream_;
esplusplayer_stream_type type_;
+ guint64 pts = 0L;
+
+ const uint64_t ES_DEFAULT_VIDEO_PTS_OFFSET;
+ const uint64_t ES_DEFAULT_AUDIO_PTS_OFFSET;
};
#endif // __PLUSPLAYER_UT_INCLUDE_ES_READER_H__
new EsPlayerEventCallback(esplayer_, video_reader_, audio_reader_);
callback_->SetCallback();
+ EXPECT_EQ(sound_manager_create_stream_information
+ (static_cast<sound_stream_type_e>(0), NULL, NULL, &stream_info_),
+ SOUND_MANAGER_ERROR_NONE);
+
std::cout << "SetUp()" << std::endl;
}
delete video_reader_;
delete audio_reader_;
+ sound_manager_destroy_stream_information(stream_info_);
+ stream_info_ = nullptr;
+
esplusplayer_destroy(esplayer_);
esplayer_ = nullptr;
std::string uri_;
EsStreamReader* video_reader_;
EsStreamReader* audio_reader_;
+ sound_stream_info_h stream_info_;
};
TEST_F(EsTest, vdapi_basic_esplusplayer_create_p_1) {
(esplusplayer_audio_codec_type)10), ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION);
}
+TEST_P(EsBasicTest, vdapi_basic_esplusplayer_set_sound_stream_info_p_1) {
+ ASSERT_EQ(esplusplayer_open(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_EQ(esplusplayer_set_display(esplayer_, ESPLUSPLAYER_DISPLAY_TYPE_OVERLAY,
+ util_.GetWindow()), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(video_reader_->SetStreamInfo(esplayer_));
+ ASSERT_TRUE(audio_reader_->SetStreamInfo(esplayer_));
+
+ ASSERT_EQ(esplusplayer_set_sound_stream_info(esplayer_, stream_info_),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(esplusplayer_prepare_async(esplayer_),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(callback_->WaitForPrepareDone());
+}
+
+TEST_P(EsBasicTest, vdapi_basic_esplusplayer_set_sound_stream_info_n_1) {
+ ASSERT_EQ(esplusplayer_set_sound_stream_info(esplayer_, nullptr),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER);
+ ASSERT_EQ(esplusplayer_set_sound_stream_info(nullptr, stream_info_),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER);
+}
+
+TEST_P(EsBasicTest, vdapi_basic_esplusplayer_set_sound_stream_info_n_2) {
+ ASSERT_EQ(esplusplayer_set_sound_stream_info(esplayer_, stream_info_),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION);
+}
+
+TEST_P(EsBasicTest, vdapi_basic_esplusplayer_enable_video_hole_p_1) {
+ ASSERT_EQ(esplusplayer_open(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(
+ esplusplayer_set_display(esplayer_, ESPLUSPLAYER_DISPLAY_TYPE_OVERLAY,
+ util_.GetWindow()),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(video_reader_->SetStreamInfo(esplayer_));
+ ASSERT_TRUE(audio_reader_->SetStreamInfo(esplayer_));
+
+ ASSERT_EQ(esplusplayer_set_video_frame_buffer_type(
+ esplayer_, ESPLUSPLAYER_DECODED_VIDEO_FRAME_BUFFER_TYPE_COPY),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(esplusplayer_enable_video_hole(esplayer_, false),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ ASSERT_EQ(esplusplayer_enable_video_hole(esplayer_, true),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(esplusplayer_prepare_async(esplayer_),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(callback_->WaitForPrepareDone());
+ ASSERT_EQ(esplusplayer_start(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(3));
+
+ ASSERT_EQ(esplusplayer_enable_video_hole(esplayer_, false),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ ASSERT_EQ(esplusplayer_enable_video_hole(esplayer_, true),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ std::cout << "BasicTest, Play, END" << std::endl;
+}
+
+TEST_F(EsTest, vdapi_basic_esplusplayer_enable_video_hole_n_1) {
+ ASSERT_EQ(esplusplayer_enable_video_hole(nullptr, true),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER);
+}
+
+TEST_P(EsBasicTest, vdapi_basic_esplusplayer_enable_video_hole_n_2) {
+ ASSERT_EQ(esplusplayer_enable_video_hole(esplayer_, true),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION);
+}
+
+TEST_P(EsBasicTest, vdapi_basic_esplusplayer_enable_video_hole_n_3) {
+ ASSERT_EQ(esplusplayer_open(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(
+ esplusplayer_set_display(esplayer_, ESPLUSPLAYER_DISPLAY_TYPE_OVERLAY,
+ util_.GetWindow()),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(video_reader_->SetStreamInfo(esplayer_));
+ ASSERT_TRUE(audio_reader_->SetStreamInfo(esplayer_));
+
+ ASSERT_EQ(esplusplayer_prepare_async(esplayer_),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(callback_->WaitForPrepareDone());
+
+ ASSERT_EQ(esplusplayer_enable_video_hole(esplayer_, false),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION);
+}
+
INSTANTIATE_TEST_CASE_P(ESPP_Basic, EsBasicTest,
::testing::ValuesIn(es_tc::tc_list));
--- /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 <string>
+#include <thread>
+
+#include "gmock/gmock.h"
+#include "gst/gst.h"
+#include "gtest/gtest.h"
+
+#include "esplusplayer_capi/esplusplayer_capi.h"
+#include "ut/include/appwindow.h"
+#include "ut/include/esplusplayer/eseventlistener.hpp"
+#include "ut/include/esplusplayer/esreader.hpp"
+// #include "ut/include/esplusplayer/tclist.h"
+#include "ut/include/streamreader.hpp"
+#include "ut/include/plusplayer/utility.h"
+
+using namespace esplusplayer;
+using namespace utils;
+
+using utils::Utility;
+
+namespace es_tc_timeunit {
+ static const std::string es_h264_aac = "es_h264_aac/";
+ static const std::string es_hevc_ac3 = "es_hevc_ac3/";
+ static const std::string es_vp9_opus = "es_vp9_opus/";
+ std::vector<std::string> tc_list = {
+ es_h264_aac,
+ //es_hevc_ac3,
+ //es_vp9_opus,
+ };
+}
+
+class EsTimeunitTest : public ::testing::TestWithParam<std::string> {
+ public:
+ EsTimeunitTest() : util_(Utility::Instance()), esplayer_(nullptr), callback_(nullptr),
+ uri_(), video_reader_(nullptr), audio_reader_(nullptr) {
+ std::cout << "EsTimeunitTest()" << std::endl;
+ }
+ ~EsTimeunitTest() { std::cout << "~EsTimeunitTest()" << std::endl; }
+
+ static void SetUpTestCase() {
+ if (!gst_init_check(nullptr, nullptr, nullptr)) {
+ std::cout << "gst init failed" << std::endl;
+ return;
+ }
+ ESPacketDownloader::Init();
+ std::cout << "SetUpTestCase()" << std::endl;
+ }
+ static void TearDownTestCase() {
+ std::cout << "TearDownTestCase()" << std::endl;
+ }
+
+ virtual void SetUp() override { std::cout << "SetUp()" << std::endl; }
+
+ virtual void TearDown() override {
+ if (nullptr != esplayer_) {
+ ASSERT_EQ(esplusplayer_close(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ }
+ if (callback_)
+ delete callback_;
+ if (video_reader_)
+ delete video_reader_;
+ if (audio_reader_)
+ delete audio_reader_;
+
+ esplusplayer_destroy(esplayer_);
+ esplayer_ = nullptr;
+
+ std::cout << "TearDown()" << std::endl;
+ }
+
+ void InitPlayer(esplusplayer_time_unit_type timeunit) {
+ uri_ = GetParam();
+ std::cout << "uri_: " << uri_ << std::endl;
+ video_reader_ =
+ new EsStreamReader(uri_ + "video/", ESPLUSPLAYER_STREAM_TYPE_VIDEO, timeunit);
+ audio_reader_ =
+ new EsStreamReader(uri_ + "audio/", ESPLUSPLAYER_STREAM_TYPE_AUDIO, timeunit);
+
+ esplayer_ = esplusplayer_create();
+ callback_ =
+ new EsPlayerEventCallback(esplayer_, video_reader_, audio_reader_);
+ callback_->SetCallback();
+
+ ASSERT_EQ(esplusplayer_open(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_EQ(esplusplayer_set_display(esplayer_, ESPLUSPLAYER_DISPLAY_TYPE_OVERLAY,
+ util_.GetWindow()), ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_TRUE(video_reader_->SetStreamInfo(esplayer_));
+ ASSERT_TRUE(audio_reader_->SetStreamInfo(esplayer_));
+ }
+
+ public:
+
+ Utility& util_;
+ esplusplayer_handle esplayer_;
+ EsPlayerEventCallback* callback_;
+
+ std::string uri_;
+ EsStreamReader* video_reader_;
+ EsStreamReader* audio_reader_;
+};
+
+TEST_P(EsTimeunitTest, vdapi_timeunit_esplusplayer_set_timeunit_type_p_1) {
+ InitPlayer(ESPLUSPLAYER_TIME_UNIT_MS);
+
+ ASSERT_EQ(esplusplayer_set_timeunit_type(esplayer_, ESPLUSPLAYER_TIME_UNIT_MS),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(esplusplayer_prepare_async(esplayer_),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(callback_->WaitForPrepareDone());
+ ASSERT_EQ(esplusplayer_start(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ uint64_t cur_time = 0;
+ ASSERT_EQ(esplusplayer_get_playing_time(esplayer_, &cur_time),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::cout << "current time is " << cur_time << std::endl;
+ ASSERT_LE(cur_time, 100000);
+
+ std::cout << "BasicTest, Play, END" << std::endl;
+}
+
+TEST_P(EsTimeunitTest, vdapi_timeunit_esplusplayer_set_timeunit_type_p_2) {
+ InitPlayer(ESPLUSPLAYER_TIME_UNIT_US);
+
+ ASSERT_EQ(esplusplayer_set_timeunit_type(esplayer_, ESPLUSPLAYER_TIME_UNIT_US),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+
+ ASSERT_EQ(esplusplayer_prepare_async(esplayer_),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ ASSERT_TRUE(callback_->WaitForPrepareDone());
+ ASSERT_EQ(esplusplayer_start(esplayer_), ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+
+ uint64_t cur_time = 0;
+ ASSERT_EQ(esplusplayer_get_playing_time(esplayer_, &cur_time),
+ ESPLUSPLAYER_ERROR_TYPE_NONE);
+ std::cout << "current time is " << cur_time << std::endl;
+ ASSERT_GE(cur_time, 100000);
+
+ std::cout << "BasicTest, Play, END" << std::endl;
+}
+
+TEST_P(EsTimeunitTest, vdapi_timeunit_esplusplayer_set_timeunit_type_n_1) {
+ ASSERT_EQ(esplusplayer_set_timeunit_type(nullptr, ESPLUSPLAYER_TIME_UNIT_MS),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER);
+}
+
+TEST_P(EsTimeunitTest, vdapi_timeunit_esplusplayer_set_timeunit_type_n_2) {
+ esplayer_ = esplusplayer_create();
+ ASSERT_EQ(esplusplayer_set_timeunit_type(esplayer_, ESPLUSPLAYER_TIME_UNIT_MS),
+ ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION);
+}
+
+INSTANTIATE_TEST_CASE_P(ESPP_Timeunit, EsTimeunitTest,
+ ::testing::ValuesIn(es_tc_timeunit::tc_list));