蓝黄同步

Signed-off-by: 徐松涛 <xusongtao3@huawei.com>
This commit is contained in:
徐松涛 2024-08-28 11:53:37 +08:00
parent 5ee6729e6a
commit 160ca04fd2
5 changed files with 9 additions and 17 deletions

View File

@ -203,6 +203,7 @@ void HttpSourcePlugin::SetDownloaderBySource(std::shared_ptr<MediaSource> source
playStrategy = source->GetPlayStrategy();
mimeType_ = source->GetMimeType();
}
if (uri_.find(".mpd") != std::string::npos) {
downloader_ = std::make_shared<DownloadMonitor>(std::make_shared<DashMediaDownloader>());
if (playStrategy != nullptr) {
@ -217,19 +218,14 @@ void HttpSourcePlugin::SetDownloaderBySource(std::shared_ptr<MediaSource> source
downloader_ = std::make_shared<DownloadMonitor>(std::make_shared<HlsMediaDownloader>());
}
delayReady = false;
} else if (uri_.find(".mpd") != std::string::npos) {
downloader_ = std::make_shared<DownloadMonitor>(std::make_shared<DashMediaDownloader>());
if (playStrategy != nullptr) {
downloader_->SetPlayStrategy(playStrategy);
}
delayReady = false;
} else if (uri_.compare(0, 4, "http") == 0) { // 0 : position, 4: count
if (playStrategy != nullptr && playStrategy->duration > 0) {
uint32_t expectDuration = playStrategy->duration;
downloader_ = std::make_shared<DownloadMonitor>(std::make_shared<HttpMediaDownloader>
(uri_, expectDuration));
(source->GetSourceUri(), expectDuration));
} else {
downloader_ = std::make_shared<DownloadMonitor>(std::make_shared<HttpMediaDownloader>(uri_));
downloader_ = std::make_shared<DownloadMonitor>(std::make_shared<HttpMediaDownloader>
(source->GetSourceUri()));
}
}
if (mimeType_== AVMimeTypes::APPLICATION_M3U8) {
@ -245,7 +241,7 @@ bool HttpSourcePlugin::IsSeekToTimeSupported()
if (mimeType_ != AVMimeTypes::APPLICATION_M3U8) {
return uri_.find("m3u8") != std::string::npos || uri_.find(".mpd") != std::string::npos;
}
MEDIA_LOG_D("IsSeekToTimeSupported return true");
MEDIA_LOG_I("IsSeekToTimeSupported return true");
return true;
}
@ -282,9 +278,10 @@ Status HttpSourcePlugin::Read(int32_t streamId, std::shared_ptr<Buffer>& buffer,
readDataInfo.streamId_ = streamId;
readDataInfo.nextStreamId_ = streamId;
readDataInfo.wantReadLength_ = expectedLen;
auto result = downloader_->Read(bufData->GetWritableAddr(expectedLen), readDataInfo);
buffer->streamID = readDataInfo.nextStreamId_;
bufData->UpdateDataSize(readDataInfo.realReadLength_);
MEDIA_LOG_D("Read finished, read size = "
PUBLIC_LOG_ZU

View File

@ -19,7 +19,6 @@
#include "media_downloader.h"
#include "meta/media_types.h"
#include "plugin/source_plugin.h"
#include "meta/media_types.h"
namespace OHOS {
namespace Media {

View File

@ -18,6 +18,7 @@
#include <string>
#include "plugin/plugin_base.h"
#include "meta/media_types.h"
#include "plugin/source_plugin.h"
#include "download/downloader.h"
#include "common/media_source.h"

View File

@ -75,7 +75,6 @@ config("hls_unittest_cfg") {
]
}
#################################################################################################################
ohos_unittest("hls_media_downloader_unit_test") {
sanitize = av_codec_test_sanitize
module_out_path = module_output_path
@ -105,7 +104,6 @@ ohos_unittest("hls_media_downloader_unit_test") {
"$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
}
#################################################################################################################
ohos_unittest("hls_playlist_downloader_unit_test") {
sanitize = av_codec_test_sanitize
module_out_path = module_output_path
@ -135,7 +133,6 @@ ohos_unittest("hls_playlist_downloader_unit_test") {
"$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
}
#################################################################################################################
ohos_unittest("hls_tags_unit_test") {
sanitize = av_codec_test_sanitize
module_out_path = module_output_path
@ -165,7 +162,6 @@ ohos_unittest("hls_tags_unit_test") {
"$av_codec_root_dir/test/unittest/resources/ohos_test.xml"
}
#################################################################################################################
ohos_unittest("m3u8_unit_test") {
sanitize = av_codec_test_sanitize
module_out_path = module_output_path

View File

@ -22,11 +22,10 @@ namespace OHOS::Media::Plugins::HttpPlugin {
using namespace std;
using namespace testing::ext;
// 黑白球視頻地址
const std::map<std::string, std::string> httpHeader = {
{"User-Agent", "ABC"},
{"Referer", "DEF"}
{"Referer", "DEF"},
};
static const std::string TEST_URI_PATH = "http://127.0.0.1:46666/";
static const std::string M3U8_PATH_1 = "test_hls/testHLSEncode.m3u8";