[1.2.2] unittest: Skip tests if file does not exist in MediaTransporterTestRistPacket... 17/317117/6
authorGilbok Lee <gilbok.lee@samsung.com>
Wed, 4 Sep 2024 06:42:35 +0000 (15:42 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 5 Sep 2024 08:43:09 +0000 (17:43 +0900)
- When running unittests, the process would crash if a test file was missing.
- If the file is not found(or not readable),
  the corresponding test case is skipped instead of causing a crash.
- Split complex header file into header and source files

Change-Id: Idd0fab9fc0a87a0765d642c8cc6a194ddbe9547

packaging/capi-media-transporter.spec
unittest/include/ut_es_reader.hpp
unittest/include/ut_window.hpp
unittest/src/ut_display.cpp
unittest/src/ut_es_reader.cpp [new file with mode: 0644]
unittest/src/ut_rist_media_packet_sender.cpp

index db2b50310ac2bb097bc42f7357f6bd190aa92be0..91253488cc148a790e71bdeb38b0d6c1f10c1f2c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-transporter
 Summary:    A Media Transporter library in Tizen Native API
-Version:    1.2.1
+Version:    1.2.2
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ca9f96bf772ecef483788e2d2cb23f20ca2728ac..3925b436d3a875cecc834437749d59570e3c038b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2024 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.
@@ -20,6 +20,7 @@
 #include <glib.h>
 #include <string>
 #include <fstream>
+#include <unistd.h>
 
 #include <dlog.h>
 #include <mtpr.h>
@@ -58,284 +59,28 @@ typedef enum {
 
 static const std::string tc_root_dir = "/home/owner/";
 
-class EsStreamReader {
+class EsStreamReader
+{
 public:
        EsStreamReader(const std::string& dirpath,
-                                       contentsType type)
-               : _dirPath(tc_root_dir + dirpath) {
-               _ESDataFile = _dirPath + "MTPR.es";
-               _ESInfoFile = _dirPath + "MTPR.info";
-               _type = type;
-               LOGD("ES data file %s", _ESDataFile.c_str());
-               makeMediaFormat();
-       }
-       ~EsStreamReader() {
-               LOGD("[tearDown] ES data file %s", _ESDataFile.c_str());
-               if (_stream.is_open()) {
-                       _stream.close();
-               }
-
-               if (_mediaFormat)
-                       media_format_unref(_mediaFormat);
-       }
-
-       bool makeMediaFormat() {
-               media_format_create(&_mediaFormat);
-               if (_type == MEDIA_TYPE_ENCODED_AUDIO ||
-                       _type == MEDIA_TYPE_RAW_AUDIO) {
-                       uint32_t mimeType;
-                       uint32_t sampleRate;
-                       uint32_t channels;
-                       uint32_t bit;
-                       auto formatStream = std::ifstream(_ESInfoFile, std::ifstream::in);
-                       if (!formatStream.is_open()) {
-                               LOGW("No audio info file: %s", _ESInfoFile.c_str());
-                               return false;
-                       }
-                       formatStream >> mimeType >> sampleRate >> channels >> bit;
-                       LOGD("mime_type: %u, sampleRate: %u, channels: %u, bit: %u",
-                               mimeType, sampleRate, channels, bit);
-                       formatStream.close();
-
-                       _rawAudioReadSize = channels * bit / 8 * 1024;
-
-                       media_format_set_audio_mime(_mediaFormat, static_cast<media_format_mimetype_e>(mimeType));
-                       media_format_set_audio_samplerate(_mediaFormat, sampleRate);
-                       media_format_set_audio_channel(_mediaFormat, channels);
-                       if (bit)
-                               media_format_set_audio_bit(_mediaFormat, bit);
-
-                       return true;
-
-               } else if (_type == MEDIA_TYPE_ENCODED_VIDEO ||
-                               _type == MEDIA_TYPE_RAW_VIDEO) {
-                       uint32_t mimeType;
-                       uint32_t width;
-                       uint32_t height;
-                       uint32_t frameRate;
-                       auto formatStream = std::ifstream(_ESInfoFile, std::ifstream::in);
-                       if (!formatStream.is_open()) {
-                               LOGW("No video info file: %s", _ESInfoFile.c_str());
-                               return false;
-                       }
-                       formatStream >> mimeType >> width >> height >> frameRate;
-                       LOGD("mime_type: %u, width: %u, height: %u, frameRate: %u",
-                               mimeType, width, height, frameRate);
-                       formatStream.close();
-
-                       _rawVideoReadSize = width * height * 3 / 2;
-
-                       media_format_set_video_mime(_mediaFormat, static_cast<media_format_mimetype_e>(mimeType));
-                       media_format_set_video_width(_mediaFormat, width);
-                       media_format_set_video_height(_mediaFormat, height);
-                       media_format_set_video_frame_rate(_mediaFormat, frameRate);
-
-                       return true;
-               }
-               return false;
-       }
+                                       contentsType type);
+       ~EsStreamReader();
 
+       bool makeMediaFormat();
        media_format_h getMediaFormat() const { return _mediaFormat; }
+       bool readNextPacket(media_packet_h* outPacket);
 
-       bool ReadNextPacket(media_packet_h* outPacket) {
-               static uint64_t pts = 0L;
-               uint64_t ptsOffset = 0L;
-               int size = 0;
-               media_packet_h packet;
-
-               if (!_stream.is_open()) {
-                       _stream = std::ifstream(_ESDataFile, std::ifstream::binary);
-                       if (!_stream.is_open()) return false;
-               }
-
-               if (_stream.eof() || GetFileLeftSize_() < 24) {
-                       LOGW("stream EOF");
-                       return false;
-               }
-
-               if (_mediaFormat == nullptr) {
-                       LOGW("mediaFormat not set");
-                       return false;
-               }
-
-               char* tmp = new char[1000000];
-
-               switch (_type)
-               {
-               case MEDIA_TYPE_ENCODED_VIDEO:
-                       size = videobytestream2nalunit(tmp);
-                       ptsOffset = ES_DEFAULT_VIDEO_PTS_OFFSET;
-                       break;
-               case MEDIA_TYPE_ENCODED_AUDIO:
-                       size = audiobytestream2nalunit(tmp);
-                       ptsOffset = ES_DEFAULT_AUDIO_PTS_OFFSET;
-                       break;
-               case MEDIA_TYPE_RAW_VIDEO:
-                       size = videoRawUnit(tmp);
-                       ptsOffset = ES_DEFAULT_VIDEO_PTS_OFFSET;
-                       break;
-               case MEDIA_TYPE_RAW_AUDIO:
-                       size = audioRawUnit(tmp);
-                       ptsOffset = ES_DEFAULT_AUDIO_PTS_OFFSET;
-                       break;
-               default:
-                       return false;
-               }
-
-               if (size <= 0) {
-                       delete[] tmp;
-                       return false;
-               }
-
-               void *buffer = nullptr;
-               media_packet_new_alloc(_mediaFormat, nullptr, nullptr, &packet);
-               media_packet_set_pts(packet, pts);
-               media_packet_set_duration(packet, ptsOffset);
-               media_packet_set_buffer_size(packet, size);
-               media_packet_get_buffer_data_ptr(packet, &buffer);
-
-               memcpy(buffer, tmp, size);
-
-               pts += ptsOffset;
-
-               *outPacket = packet;
-
-               delete[] tmp;
-               return true;
-       }
-
-       void ResetReader() {
-               _stream.seekg(0,std::ios::beg);
-       }
+       void resetReader() { _stream.seekg(0,std::ios::beg); }
 
 private:
-       int videobytestream2nalunit(char *nal)
-       {
-               int nal_length = 0;
-               int read_size = 1;
-               char buffer[1000000];
-               unsigned char i;
-               int type = 0;
-
-               do {
-                       unsigned char zero_count = 0;
-
-                       _stream.read(buffer, read_size);
-
-                       unsigned char val = buffer[0];
-                       nal[nal_length++] = val;
-                       while (1) {
-                               if ((zero_count == 2 || zero_count == 3) && val == 1)
-                                       break;
-                               zero_count++;
-                               _stream.read(buffer, read_size);
-
-                               val = buffer[0];
-                               nal[nal_length++] = val;
-                       }
-
-                       zero_count = 0;
-                       int init = 1;
-
-                       while (1) {
-                               if (_stream.eof())
-                                       return -1;
-
-                               _stream.read(buffer, read_size);
-
-                               val = buffer[0];
-
-                               if (init) {
-                                       type = val & 0x1F;
-                                       init = 0;
-                               }
-
-                               if (!val) {
-                                       zero_count++;
-                               } else {
-                                       if ((zero_count == 2 || zero_count == 3 || zero_count == 4)
-                                               && (val == 1)) {
-                                               break;
-                                       } else {
-                                               for (i = 0; i < zero_count; i++)
-                                                       nal[nal_length++] = 0;
-                                               nal[nal_length++] = val;
-                                               zero_count = 0;
-                                       }
-                               }
-                       }
-
-                       _stream.seekg(-(zero_count + 1), std::ios::cur);
-               } while (type == NAL_SEI ||
-                               type == NAL_SEQUENCE_PARAMETER_SET ||
-                               type == NAL_PICTURE_PARAMETER_SET ||
-                               type == NAL_PICTURE_DELIMITER);
-
-
-               return nal_length;
-       }
-
-       int audiobytestream2nalunit(char *nal)
-       {
-               const int HEADER_SIZE = 7;
-               int nal_length = 0;
-               int audio_data_length = 0;
-
-               if (nal == NULL || _stream.eof())
-                       return -1;
-
-               _stream.read(nal, HEADER_SIZE);
-
-               nal_length = static_cast<int>(((nal[4] << 3) & 0x7ff)
-                       + (((nal[5] - 0x1f) >> 5) & 0x7));
-
-               audio_data_length = nal_length - HEADER_SIZE;
-               _stream.read(nal + HEADER_SIZE, audio_data_length);
-
-               return nal_length;
-       }
-
-       int audioRawUnit(char *nal)
-       {
-               if (!_rawAudioReadSize) {
-                       LOGE("audio read size is zero");
-                       return -1;
-               }
-
-               if (GetFileLeftSize_() < _rawAudioReadSize)
-                       return -1;
-
-               _stream.read(nal, _rawAudioReadSize);
-
-               return _rawAudioReadSize;
-       }
-
-       int videoRawUnit(char *nal)
-       {
-               if (!_rawVideoReadSize) {
-                       LOGE("video read size is zero");
-                       return -1;
-               }
-
-               if (GetFileLeftSize_() < _rawVideoReadSize)
-                       return -1;
-
-               _stream.read(nal, _rawVideoReadSize);
-
-               return _rawVideoReadSize;
-       }
-
-       int GetFileLeftSize_(void) {
-               if (!_stream.is_open()) return 0;
-               int cur = _stream.tellg();
-               _stream.seekg(0, _stream.end);
-               int total = _stream.tellg();
-               _stream.seekg(cur);
-               return total - cur;
-       }
+       int videobytestream2nalunit(char *nal);
+       int audiobytestream2nalunit(char *nal);
+       int audioRawUnit(char *nal);
+       int videoRawUnit(char *nal);
+       int getFileLeftSize_(void);
+       void verifyInputFiles_();
 
 private:
-       std::string _dirPath;
        std::string _ESDataFile;
        std::string _ESInfoFile;
        std::ifstream _stream;
index e69308fb0922cfcc30924d0ae608ae36508df805..3d0de855ee608843e1fc217620d53aad1f2018c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2024 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.
index f16eb766e8b74e557796d685b9d8bd7ed5f052d1..7e8c6af2bb7abd6de4d7ff6bec07aa28b27077f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2024 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.
diff --git a/unittest/src/ut_es_reader.cpp b/unittest/src/ut_es_reader.cpp
new file mode 100644 (file)
index 0000000..32121d6
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2024 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 "ut_es_reader.hpp"
+
+EsStreamReader::EsStreamReader(const std::string& dirpath, contentsType type) :
+               _ESDataFile(tc_root_dir + dirpath + "MTPR.es"),
+               _ESInfoFile(tc_root_dir + dirpath + "MTPR.info"),
+               _type(type)
+{
+       LOGD("ES data file %s", _ESDataFile.c_str());
+       verifyInputFiles_();
+       makeMediaFormat();
+}
+
+EsStreamReader::~EsStreamReader()
+{
+       LOGD("[tearDown] ES data file %s", _ESDataFile.c_str());
+       if (_stream.is_open()) {
+               _stream.close();
+       }
+
+       if (_mediaFormat)
+               media_format_unref(_mediaFormat);
+}
+
+bool EsStreamReader::makeMediaFormat()
+{
+       media_format_create(&_mediaFormat);
+       if (_type == MEDIA_TYPE_ENCODED_AUDIO ||
+               _type == MEDIA_TYPE_RAW_AUDIO) {
+               uint32_t mimeType;
+               uint32_t sampleRate;
+               uint32_t channels;
+               uint32_t bit;
+               auto formatStream = std::ifstream(_ESInfoFile, std::ifstream::in);
+               if (!formatStream.is_open()) {
+                       LOGW("No audio info file: %s", _ESInfoFile.c_str());
+                       return false;
+               }
+               formatStream >> mimeType >> sampleRate >> channels >> bit;
+               LOGD("mime_type: %u, sampleRate: %u, channels: %u, bit: %u",
+                       mimeType, sampleRate, channels, bit);
+               formatStream.close();
+
+               _rawAudioReadSize = channels * bit / 8 * 1024;
+
+               media_format_set_audio_mime(_mediaFormat, static_cast<media_format_mimetype_e>(mimeType));
+               media_format_set_audio_samplerate(_mediaFormat, sampleRate);
+               media_format_set_audio_channel(_mediaFormat, channels);
+               if (bit)
+                       media_format_set_audio_bit(_mediaFormat, bit);
+
+               return true;
+
+       } else if (_type == MEDIA_TYPE_ENCODED_VIDEO ||
+                       _type == MEDIA_TYPE_RAW_VIDEO) {
+               uint32_t mimeType;
+               uint32_t width;
+               uint32_t height;
+               uint32_t frameRate;
+               auto formatStream = std::ifstream(_ESInfoFile, std::ifstream::in);
+               if (!formatStream.is_open()) {
+                       LOGW("No video info file: %s", _ESInfoFile.c_str());
+                       return false;
+               }
+               formatStream >> mimeType >> width >> height >> frameRate;
+               LOGD("mime_type: %u, width: %u, height: %u, frameRate: %u",
+                       mimeType, width, height, frameRate);
+               formatStream.close();
+
+               _rawVideoReadSize = width * height * 3 / 2;
+
+               media_format_set_video_mime(_mediaFormat, static_cast<media_format_mimetype_e>(mimeType));
+               media_format_set_video_width(_mediaFormat, width);
+               media_format_set_video_height(_mediaFormat, height);
+               media_format_set_video_frame_rate(_mediaFormat, frameRate);
+
+               return true;
+       }
+       return false;
+}
+
+bool EsStreamReader::readNextPacket(media_packet_h* outPacket)
+{
+       static uint64_t pts = 0L;
+       uint64_t ptsOffset = 0L;
+       int size = 0;
+       media_packet_h packet;
+
+       if (!_stream.is_open()) {
+               _stream = std::ifstream(_ESDataFile, std::ifstream::binary);
+               if (!_stream.is_open()) return false;
+       }
+
+       if (_stream.eof() || getFileLeftSize_() < 24) {
+               LOGW("stream EOF");
+               return false;
+       }
+
+       if (_mediaFormat == nullptr) {
+               LOGW("mediaFormat not set");
+               return false;
+       }
+
+       char* tmp = new char[1000000];
+
+       switch (_type)
+       {
+       case MEDIA_TYPE_ENCODED_VIDEO:
+               size = videobytestream2nalunit(tmp);
+               ptsOffset = ES_DEFAULT_VIDEO_PTS_OFFSET;
+               break;
+       case MEDIA_TYPE_ENCODED_AUDIO:
+               size = audiobytestream2nalunit(tmp);
+               ptsOffset = ES_DEFAULT_AUDIO_PTS_OFFSET;
+               break;
+       case MEDIA_TYPE_RAW_VIDEO:
+               size = videoRawUnit(tmp);
+               ptsOffset = ES_DEFAULT_VIDEO_PTS_OFFSET;
+               break;
+       case MEDIA_TYPE_RAW_AUDIO:
+               size = audioRawUnit(tmp);
+               ptsOffset = ES_DEFAULT_AUDIO_PTS_OFFSET;
+               break;
+       default:
+               return false;
+       }
+
+       if (size <= 0) {
+               delete[] tmp;
+               return false;
+       }
+
+       void *buffer = nullptr;
+       media_packet_new_alloc(_mediaFormat, nullptr, nullptr, &packet);
+       media_packet_set_pts(packet, pts);
+       media_packet_set_duration(packet, ptsOffset);
+       media_packet_set_buffer_size(packet, size);
+       media_packet_get_buffer_data_ptr(packet, &buffer);
+
+       memcpy(buffer, tmp, size);
+
+       pts += ptsOffset;
+
+       *outPacket = packet;
+
+       delete[] tmp;
+       return true;
+}
+
+int EsStreamReader::videobytestream2nalunit(char *nal)
+{
+       int nal_length = 0;
+       int read_size = 1;
+       char buffer[1000000];
+       unsigned char i;
+       int type = 0;
+
+       do {
+               unsigned char zero_count = 0;
+
+               _stream.read(buffer, read_size);
+
+               unsigned char val = buffer[0];
+               nal[nal_length++] = val;
+               while (1) {
+                       if ((zero_count == 2 || zero_count == 3) && val == 1)
+                               break;
+                       zero_count++;
+                       _stream.read(buffer, read_size);
+
+                       val = buffer[0];
+                       nal[nal_length++] = val;
+               }
+
+               zero_count = 0;
+               int init = 1;
+
+               while (1) {
+                       if (_stream.eof())
+                               return -1;
+
+                       _stream.read(buffer, read_size);
+
+                       val = buffer[0];
+
+                       if (init) {
+                               type = val & 0x1F;
+                               init = 0;
+                       }
+
+                       if (!val) {
+                               zero_count++;
+                       } else {
+                               if ((zero_count == 2 || zero_count == 3 || zero_count == 4)
+                                       && (val == 1)) {
+                                       break;
+                               } else {
+                                       for (i = 0; i < zero_count; i++)
+                                               nal[nal_length++] = 0;
+                                       nal[nal_length++] = val;
+                                       zero_count = 0;
+                               }
+                       }
+               }
+
+               _stream.seekg(-(zero_count + 1), std::ios::cur);
+       } while (type == NAL_SEI ||
+                       type == NAL_SEQUENCE_PARAMETER_SET ||
+                       type == NAL_PICTURE_PARAMETER_SET ||
+                       type == NAL_PICTURE_DELIMITER);
+
+
+       return nal_length;
+}
+
+int EsStreamReader::audiobytestream2nalunit(char *nal)
+{
+       const int HEADER_SIZE = 7;
+       int nal_length = 0;
+       int audio_data_length = 0;
+
+       if (nal == NULL || _stream.eof())
+               return -1;
+
+       _stream.read(nal, HEADER_SIZE);
+
+       nal_length = static_cast<int>(((nal[4] << 3) & 0x7ff)
+               + (((nal[5] - 0x1f) >> 5) & 0x7));
+
+       audio_data_length = nal_length - HEADER_SIZE;
+       _stream.read(nal + HEADER_SIZE, audio_data_length);
+
+       return nal_length;
+}
+
+int EsStreamReader::audioRawUnit(char *nal)
+{
+       if (!_rawAudioReadSize) {
+               LOGE("audio read size is zero");
+               return -1;
+       }
+
+       if (getFileLeftSize_() < _rawAudioReadSize)
+               return -1;
+
+       _stream.read(nal, _rawAudioReadSize);
+
+       return _rawAudioReadSize;
+}
+
+int EsStreamReader::videoRawUnit(char *nal)
+{
+       if (!_rawVideoReadSize) {
+               LOGE("video read size is zero");
+               return -1;
+       }
+
+       if (getFileLeftSize_() < _rawVideoReadSize)
+               return -1;
+
+       _stream.read(nal, _rawVideoReadSize);
+
+       return _rawVideoReadSize;
+}
+
+int EsStreamReader::getFileLeftSize_(void) {
+       if (!_stream.is_open()) return 0;
+       int cur = _stream.tellg();
+       _stream.seekg(0, _stream.end);
+       int total = _stream.tellg();
+       _stream.seekg(cur);
+       return total - cur;
+}
+
+void EsStreamReader::verifyInputFiles_() {
+       if (access(_ESDataFile.c_str(), R_OK) == -1)
+               throw std::runtime_error("file not found/not readable");
+
+       if (access(_ESInfoFile.c_str(), R_OK) == -1)
+               throw std::runtime_error("file not found/not readable");
+}
index d10720f61fd87a3daab25111e1bae80a4a40f18f..55e25a9ee84ad152c01e89158421796d24cbb7c5 100644 (file)
@@ -110,7 +110,7 @@ std::thread MediaTransporterTestRistPacketSender::feedingEsPacket(mtpr_h mtpr,
                while (leftFeedingPacket--) {
                        media_packet_h pkt = nullptr;
 
-                       if (!reader->ReadNextPacket(&pkt))
+                       if (!reader->readNextPacket(&pkt))
                                break;
 
                        mtpr_media_packet_source_push_packet(mtpr, source_id, pkt);
@@ -148,7 +148,11 @@ TEST_F(MediaTransporterTestRistPacketSender, set_media_format)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       try {
+               _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _videoEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -166,7 +170,11 @@ TEST_F(MediaTransporterTestRistPacketSender, push_media_video_packet)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       try {
+               _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _videoEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -191,7 +199,11 @@ TEST_F(MediaTransporterTestRistPacketSender, push_media_audio_packet)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _audioEsReader = new EsStreamReader("audio/", MEDIA_TYPE_ENCODED_AUDIO);
+       try {
+               _audioEsReader = new EsStreamReader("audio/", MEDIA_TYPE_ENCODED_AUDIO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No audio file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _audioEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -221,8 +233,17 @@ TEST_F(MediaTransporterTestRistPacketSender, push_media_av_packet)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(videoSourceID, 0);
 
-       _audioEsReader = new EsStreamReader("audio/", MEDIA_TYPE_ENCODED_AUDIO);
-       _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       try {
+               _audioEsReader = new EsStreamReader("audio/", MEDIA_TYPE_ENCODED_AUDIO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No audio file exists.";
+       }
+
+       try {
+               _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, audioSourceID, _audioEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -255,7 +276,11 @@ TEST_F(MediaTransporterTestRistPacketSender, set_buffer_state_callback)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       try {
+               _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _videoEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -288,7 +313,11 @@ TEST_F(MediaTransporterTestRistPacketSender, unset_buffer_state_callback)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       try {
+               _videoEsReader = new EsStreamReader("video/", MEDIA_TYPE_ENCODED_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _videoEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -320,7 +349,11 @@ TEST_F(MediaTransporterTestRistPacketSender, push_media_raw_video_packet)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _videoEsReader = new EsStreamReader("raw_video/", MEDIA_TYPE_RAW_VIDEO);
+       try {
+               _videoEsReader = new EsStreamReader("raw_video/", MEDIA_TYPE_RAW_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No raw_video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _videoEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -345,7 +378,11 @@ TEST_F(MediaTransporterTestRistPacketSender, push_media_raw_audio_packet)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(source_id, 0);
 
-       _audioEsReader = new EsStreamReader("raw_audio/", MEDIA_TYPE_RAW_AUDIO);
+       try {
+               _audioEsReader = new EsStreamReader("raw_audio/", MEDIA_TYPE_RAW_AUDIO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No raw_audio file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, source_id, _audioEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);
@@ -375,8 +412,12 @@ TEST_F(MediaTransporterTestRistPacketSender, push_media_raw_av_packet)
        ASSERT_EQ(ret, MTPR_ERROR_NONE);
        ASSERT_GE(videoSourceID, 0);
 
-       _audioEsReader = new EsStreamReader("raw_audio/", MEDIA_TYPE_RAW_AUDIO);
-       _videoEsReader = new EsStreamReader("raw_video/", MEDIA_TYPE_RAW_VIDEO);
+       try {
+               _audioEsReader = new EsStreamReader("raw_audio/", MEDIA_TYPE_RAW_AUDIO);
+               _videoEsReader = new EsStreamReader("raw_video/", MEDIA_TYPE_RAW_VIDEO);
+       } catch (std::runtime_error& e) {
+               GTEST_SKIP() << "Skipping Test. No raw_audio/raw_video file exists.";
+       }
 
        ret = mtpr_media_packet_source_set_format(_mtpr, audioSourceID, _audioEsReader->getMediaFormat());
        EXPECT_EQ(ret, MTPR_ERROR_NONE);