Skip to content

Commit

Permalink
Change SetStreamingProperty parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaowei-guan committed Feb 29, 2024
1 parent 184301a commit ef19044
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
10 changes: 7 additions & 3 deletions packages/video_player_avplay/lib/src/video_player_tizen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

Expand Down Expand Up @@ -42,7 +40,13 @@ class VideoPlayerTizen extends VideoPlayerPlatform {
message.httpHeaders = dataSource.httpHeaders;
message.drmConfigs = dataSource.drmConfigs?.toMap();
message.playerOptions = dataSource.playerOptions;
message.streamingProperty = dataSource.streamingProperty;
message.streamingProperty = dataSource.streamingProperty == null
? null
: <String, String>{
for (final MapEntry<StreamingPropertyType, String> entry
in dataSource.streamingProperty!.entries)
_streamingPropertyType[entry.key]!: entry.value
};
break;
case DataSourceType.file:
message.uri = dataSource.uri;
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player_avplay/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
/// Sets specific feature values for HTTP, MMS, or specific streaming engine (Smooth Streaming, HLS, DASH, DivX Plus Streaming, or Widevine).
/// The available streaming properties depend on the streaming protocol or engine.
/// Only for [VideoPlayerController.network].
final Map<String, String>? streamingProperty;
final Map<StreamingPropertyType, String>? streamingProperty;

/// **Android only**. Will override the platform's generic file format
/// detection with whatever is set here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class DataSource {
Map<String, dynamic>? playerOptions;

/// Sets specific feature values for HTTP, MMS, or specific streaming engine
Map<String, String>? streamingProperty;
Map<StreamingPropertyType, String>? streamingProperty;
}

/// The way in which the video was originally loaded.
Expand Down
6 changes: 3 additions & 3 deletions packages/video_player_avplay/tizen/src/media_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ int64_t MediaPlayer::Create(const std::string &uri,
return -1;
}

std::string cookie = flutter_common::GetValue(create_message.http_headers(),
"Cookie", std::string());
std::string cookie = flutter_common::GetValue(
create_message.streaming_property(), "COOKIE", std::string());
if (!cookie.empty()) {
int ret =
player_set_streaming_cookie(player_, cookie.c_str(), cookie.size());
Expand All @@ -97,7 +97,7 @@ int64_t MediaPlayer::Create(const std::string &uri,
}
}
std::string user_agent = flutter_common::GetValue(
create_message.http_headers(), "User-Agent", std::string());
create_message.streaming_property(), "USER_AGENT", std::string());
if (!user_agent.empty()) {
int ret = player_set_streaming_user_agent(player_, user_agent.c_str(),
user_agent.size());
Expand Down
22 changes: 7 additions & 15 deletions packages/video_player_avplay/tizen/src/plus_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,12 @@ int64_t PlusPlayer::Create(const std::string &uri,
return -1;
}

std::string cookie = flutter_common::GetValue(create_message.http_headers(),
"Cookie", std::string());
if (!cookie.empty()) {
SetStreamingProperty(player_, "COOKIE", cookie);
}
std::string user_agent = flutter_common::GetValue(
create_message.http_headers(), "User-Agent", std::string());
if (!user_agent.empty()) {
SetStreamingProperty(player_, "USER_AGENT", user_agent);
}
std::string adaptive_info = flutter_common::GetValue(
create_message.streaming_property(), "ADAPTIVE_INFO", std::string());
if (!adaptive_info.empty()) {
SetStreamingProperty(player_, "ADAPTIVE_INFO", adaptive_info);
if (create_message.streaming_property() != nullptr &&
!create_message.streaming_property()->empty()) {
for (const auto &[key, value] : *create_message.streaming_property()) {
SetStreamingProperty(player_, std::get<std::string>(key),
std::get<std::string>(value));
}
}

if (!Open(player_, uri)) {
Expand Down Expand Up @@ -585,7 +577,7 @@ std::string PlusPlayer::GetStreamingProperty(
}
plusplayer::State state = GetState(player_);
if (state == plusplayer::State::kNone || state == plusplayer::State::kIdle) {
LOG_ERROR("[PIE]:Player is in invalid state[%d]", state);
LOG_ERROR("[PlusPlayer]:Player is in invalid state[%d]", state);
return "";
}
return ::GetStreamingProperty(player_, streaming_property_type);
Expand Down

0 comments on commit ef19044

Please sign in to comment.