Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[video_player_avplay] Call the open before calling the SetStreamingProperty #725

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player_avplay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Call the open before calling the SetStreamingProperty.

## 0.4.7

* Add SetBufferConfig interface.
Expand Down
49 changes: 9 additions & 40 deletions packages/video_player_avplay/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,32 +364,6 @@ class DurationMessage {
}
}

class StreamingPropertyMessage {
StreamingPropertyMessage({
required this.playerId,
required this.streamingProperty,
});

int playerId;

String streamingProperty;

Object encode() {
return <Object?>[
playerId,
streamingProperty,
];
}

static StreamingPropertyMessage decode(Object result) {
result as List<Object?>;
return StreamingPropertyMessage(
playerId: result[0]! as int,
streamingProperty: result[1]! as String,
);
}
}

class StreamingPropertyTypeMessage {
StreamingPropertyTypeMessage({
required this.playerId,
Expand Down Expand Up @@ -481,20 +455,17 @@ class _VideoPlayerAvplayApiCodec extends StandardMessageCodec {
} else if (value is SelectedTracksMessage) {
buffer.putUint8(137);
writeValue(buffer, value.encode());
} else if (value is StreamingPropertyMessage) {
buffer.putUint8(138);
writeValue(buffer, value.encode());
} else if (value is StreamingPropertyTypeMessage) {
buffer.putUint8(139);
buffer.putUint8(138);
writeValue(buffer, value.encode());
} else if (value is TrackMessage) {
buffer.putUint8(140);
buffer.putUint8(139);
writeValue(buffer, value.encode());
} else if (value is TrackTypeMessage) {
buffer.putUint8(141);
buffer.putUint8(140);
writeValue(buffer, value.encode());
} else if (value is VolumeMessage) {
buffer.putUint8(142);
buffer.putUint8(141);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
Expand Down Expand Up @@ -525,14 +496,12 @@ class _VideoPlayerAvplayApiCodec extends StandardMessageCodec {
case 137:
return SelectedTracksMessage.decode(readValue(buffer)!);
case 138:
return StreamingPropertyMessage.decode(readValue(buffer)!);
case 139:
return StreamingPropertyTypeMessage.decode(readValue(buffer)!);
case 140:
case 139:
return TrackMessage.decode(readValue(buffer)!);
case 141:
case 140:
return TrackTypeMessage.decode(readValue(buffer)!);
case 142:
case 141:
return VolumeMessage.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
Expand Down Expand Up @@ -975,7 +944,7 @@ class VideoPlayerAvplayApi {
}
}

Future<StreamingPropertyMessage> getStreamingProperty(
Future<String> getStreamingProperty(
StreamingPropertyTypeMessage arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.video_player_avplay.VideoPlayerAvplayApi.getStreamingProperty',
Expand All @@ -1000,7 +969,7 @@ class VideoPlayerAvplayApi {
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as StreamingPropertyMessage?)!;
return (replyList[0] as String?)!;
}
}

Expand Down
8 changes: 3 additions & 5 deletions packages/video_player_avplay/lib/src/video_player_tizen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,9 @@ class VideoPlayerTizen extends VideoPlayerPlatform {
@override
Future<String> getStreamingProperty(
int playerId, StreamingPropertyType type) async {
final StreamingPropertyMessage streamingPropertyMessage =
await _api.getStreamingProperty(StreamingPropertyTypeMessage(
playerId: playerId,
streamingPropertyType: _streamingPropertyType[type]!));
return streamingPropertyMessage.streamingProperty;
return _api.getStreamingProperty(StreamingPropertyTypeMessage(
playerId: playerId,
streamingPropertyType: _streamingPropertyType[type]!));
JSUYA marked this conversation as resolved.
Show resolved Hide resolved
}

@override
Expand Down
9 changes: 1 addition & 8 deletions packages/video_player_avplay/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ class DurationMessage {
List<int?>? durationRange;
}

class StreamingPropertyMessage {
StreamingPropertyMessage(this.playerId, this.streamingProperty);
int playerId;
String streamingProperty;
}

class StreamingPropertyTypeMessage {
StreamingPropertyTypeMessage(this.playerId, this.streamingPropertyType);
int playerId;
Expand Down Expand Up @@ -129,7 +123,6 @@ abstract class VideoPlayerAvplayApi {
void pause(PlayerMessage msg);
void setMixWithOthers(MixWithOthersMessage msg);
void setDisplayGeometry(GeometryMessage msg);
StreamingPropertyMessage getStreamingProperty(
StreamingPropertyTypeMessage msg);
String getStreamingProperty(StreamingPropertyTypeMessage msg);
bool setBufferConfig(BufferConfigMessage msg);
}
67 changes: 9 additions & 58 deletions packages/video_player_avplay/tizen/src/messages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,42 +560,6 @@ DurationMessage DurationMessage::FromEncodableList(const EncodableList& list) {
return decoded;
}

// StreamingPropertyMessage

StreamingPropertyMessage::StreamingPropertyMessage(
int64_t player_id, const std::string& streaming_property)
: player_id_(player_id), streaming_property_(streaming_property) {}

int64_t StreamingPropertyMessage::player_id() const { return player_id_; }

void StreamingPropertyMessage::set_player_id(int64_t value_arg) {
player_id_ = value_arg;
}

const std::string& StreamingPropertyMessage::streaming_property() const {
return streaming_property_;
}

void StreamingPropertyMessage::set_streaming_property(
std::string_view value_arg) {
streaming_property_ = value_arg;
}

EncodableList StreamingPropertyMessage::ToEncodableList() const {
EncodableList list;
list.reserve(2);
list.push_back(EncodableValue(player_id_));
list.push_back(EncodableValue(streaming_property_));
return list;
}

StreamingPropertyMessage StreamingPropertyMessage::FromEncodableList(
const EncodableList& list) {
StreamingPropertyMessage decoded(list[0].LongValue(),
std::get<std::string>(list[1]));
return decoded;
}

// StreamingPropertyTypeMessage

StreamingPropertyTypeMessage::StreamingPropertyTypeMessage(
Expand Down Expand Up @@ -717,19 +681,16 @@ EncodableValue VideoPlayerAvplayApiCodecSerializer::ReadValueOfType(
return CustomEncodableValue(SelectedTracksMessage::FromEncodableList(
std::get<EncodableList>(ReadValue(stream))));
case 138:
return CustomEncodableValue(StreamingPropertyMessage::FromEncodableList(
std::get<EncodableList>(ReadValue(stream))));
case 139:
return CustomEncodableValue(
StreamingPropertyTypeMessage::FromEncodableList(
std::get<EncodableList>(ReadValue(stream))));
case 140:
case 139:
return CustomEncodableValue(TrackMessage::FromEncodableList(
std::get<EncodableList>(ReadValue(stream))));
case 141:
case 140:
return CustomEncodableValue(TrackTypeMessage::FromEncodableList(
std::get<EncodableList>(ReadValue(stream))));
case 142:
case 141:
return CustomEncodableValue(VolumeMessage::FromEncodableList(
std::get<EncodableList>(ReadValue(stream))));
default:
Expand Down Expand Up @@ -821,40 +782,32 @@ void VideoPlayerAvplayApiCodecSerializer::WriteValue(
stream);
return;
}
if (custom_value->type() == typeid(StreamingPropertyMessage)) {
stream->WriteByte(138);
WriteValue(
EncodableValue(std::any_cast<StreamingPropertyMessage>(*custom_value)
.ToEncodableList()),
stream);
return;
}
if (custom_value->type() == typeid(StreamingPropertyTypeMessage)) {
stream->WriteByte(139);
stream->WriteByte(138);
WriteValue(EncodableValue(
std::any_cast<StreamingPropertyTypeMessage>(*custom_value)
.ToEncodableList()),
stream);
return;
}
if (custom_value->type() == typeid(TrackMessage)) {
stream->WriteByte(140);
stream->WriteByte(139);
WriteValue(
EncodableValue(
std::any_cast<TrackMessage>(*custom_value).ToEncodableList()),
stream);
return;
}
if (custom_value->type() == typeid(TrackTypeMessage)) {
stream->WriteByte(141);
stream->WriteByte(140);
WriteValue(
EncodableValue(
std::any_cast<TrackTypeMessage>(*custom_value).ToEncodableList()),
stream);
return;
}
if (custom_value->type() == typeid(VolumeMessage)) {
stream->WriteByte(142);
stream->WriteByte(141);
WriteValue(
EncodableValue(
std::any_cast<VolumeMessage>(*custom_value).ToEncodableList()),
Expand Down Expand Up @@ -1482,15 +1435,13 @@ void VideoPlayerAvplayApi::SetUp(flutter::BinaryMessenger* binary_messenger,
const auto& msg_arg =
std::any_cast<const StreamingPropertyTypeMessage&>(
std::get<CustomEncodableValue>(encodable_msg_arg));
ErrorOr<StreamingPropertyMessage> output =
api->GetStreamingProperty(msg_arg);
ErrorOr<std::string> output = api->GetStreamingProperty(msg_arg);
if (output.has_error()) {
reply(WrapError(output.error()));
return;
}
EncodableList wrapped;
wrapped.push_back(
CustomEncodableValue(std::move(output).TakeValue()));
wrapped.push_back(EncodableValue(std::move(output).TakeValue()));
reply(EncodableValue(std::move(wrapped)));
} catch (const std::exception& exception) {
reply(WrapError(exception.what()));
Expand Down
25 changes: 1 addition & 24 deletions packages/video_player_avplay/tizen/src/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,29 +365,6 @@ class DurationMessage {
std::optional<flutter::EncodableList> duration_range_;
};

// Generated class from Pigeon that represents data sent in messages.
class StreamingPropertyMessage {
public:
// Constructs an object setting all fields.
explicit StreamingPropertyMessage(int64_t player_id,
const std::string& streaming_property);

int64_t player_id() const;
void set_player_id(int64_t value_arg);

const std::string& streaming_property() const;
void set_streaming_property(std::string_view value_arg);

private:
static StreamingPropertyMessage FromEncodableList(
const flutter::EncodableList& list);
flutter::EncodableList ToEncodableList() const;
friend class VideoPlayerAvplayApi;
friend class VideoPlayerAvplayApiCodecSerializer;
int64_t player_id_;
std::string streaming_property_;
};

// Generated class from Pigeon that represents data sent in messages.
class StreamingPropertyTypeMessage {
public:
Expand Down Expand Up @@ -485,7 +462,7 @@ class VideoPlayerAvplayApi {
const MixWithOthersMessage& msg) = 0;
virtual std::optional<FlutterError> SetDisplayGeometry(
const GeometryMessage& msg) = 0;
virtual ErrorOr<StreamingPropertyMessage> GetStreamingProperty(
virtual ErrorOr<std::string> GetStreamingProperty(
const StreamingPropertyTypeMessage& msg) = 0;
virtual ErrorOr<bool> SetBufferConfig(const BufferConfigMessage& msg) = 0;

Expand Down
13 changes: 6 additions & 7 deletions packages/video_player_avplay/tizen/src/plus_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ int64_t PlusPlayer::Create(const std::string &uri,
return -1;
}

if (!Open(player_, uri)) {
LOG_ERROR("[PlusPlayer] Fail to open uri : %s.", uri.c_str());
return -1;
}
LOG_INFO("[PlusPlayer] Uri: %s", uri.c_str());

if (create_message.streaming_property() != nullptr &&
!create_message.streaming_property()->empty()) {
for (const auto &[key, value] : *create_message.streaming_property()) {
Expand All @@ -95,12 +101,6 @@ int64_t PlusPlayer::Create(const std::string &uri,
}
}

if (!Open(player_, uri)) {
LOG_ERROR("[PlusPlayer] Fail to open uri : %s.", uri.c_str());
return -1;
}
LOG_INFO("[PlusPlayer] Uri: %s", uri.c_str());

char *appId = nullptr;
int ret = app_manager_get_app_id(getpid(), &appId);
if (ret != APP_MANAGER_ERROR_NONE) {
Expand Down Expand Up @@ -345,7 +345,6 @@ std::pair<int64_t, int64_t> PlusPlayer::GetDuration() {
LOG_ERROR("[PlusPlayer] Player fail to get the duration.");
return std::make_pair(0, 0);
}
LOG_INFO("[PlusPlayer] Video duration: %lld.", duration);
JSUYA marked this conversation as resolved.
Show resolved Hide resolved
return std::make_pair(0, duration);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class VideoPlayerTizenPlugin : public flutter::Plugin,
const MixWithOthersMessage &msg) override;
std::optional<FlutterError> SetDisplayGeometry(
const GeometryMessage &msg) override;
ErrorOr<StreamingPropertyMessage> GetStreamingProperty(
ErrorOr<std::string> GetStreamingProperty(
const StreamingPropertyTypeMessage &msg) override;
ErrorOr<bool> SetBufferConfig(const BufferConfigMessage &msg) override;

Expand Down Expand Up @@ -302,16 +302,13 @@ std::optional<FlutterError> VideoPlayerTizenPlugin::SetDisplayGeometry(
return std::nullopt;
}

ErrorOr<StreamingPropertyMessage> VideoPlayerTizenPlugin::GetStreamingProperty(
ErrorOr<std::string> VideoPlayerTizenPlugin::GetStreamingProperty(
const StreamingPropertyTypeMessage &msg) {
VideoPlayer *player = FindPlayerById(msg.player_id());
if (!player) {
return FlutterError("Invalid argument", "Player not found");
}
StreamingPropertyMessage result(
msg.player_id(),
player->GetStreamingProperty(msg.streaming_property_type()));
return result;
return player->GetStreamingProperty(msg.streaming_property_type());
}

ErrorOr<bool> VideoPlayerTizenPlugin::SetBufferConfig(
Expand Down
Loading