Skip to content

Commit

Permalink
Merge pull request #1 from MaKi983/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
MaKi983 authored Jul 12, 2024
2 parents c335fa1 + 69f5a0f commit 1003901
Show file tree
Hide file tree
Showing 193 changed files with 3,785 additions and 1,553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ AVInputServiceChannel::AVInputServiceChannel(boost::asio::io_service::strand& st
void AVInputServiceChannel::receive(IAVInputServiceChannelEventHandler::Pointer eventHandler)
{
auto receivePromise = messenger::ReceivePromise::defer(strand_);
receivePromise->then(std::bind(&AVInputServiceChannel::messageHandler, this, std::placeholders::_1, eventHandler),
receivePromise->then(std::bind(&AVInputServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler),
std::bind(&IAVInputServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1));

messenger_->enqueueReceive(channelId_, std::move(receivePromise));
Expand All @@ -32,7 +32,7 @@ void AVInputServiceChannel::sendChannelOpenResponse(const proto::messages::Chann
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendChannelOpenResponse: %s", response.Utf8DebugString().c_str());

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL));
message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData());
message->insertPayload(response);

Expand All @@ -43,7 +43,7 @@ void AVInputServiceChannel::sendAVChannelSetupResponse(const proto::messages::AV
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendAVChannelSetupResponse: %s", response.Utf8DebugString().c_str());

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC));
message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::SETUP_RESPONSE).getData());
message->insertPayload(response);

Expand Down Expand Up @@ -86,7 +86,7 @@ void AVInputServiceChannel::sendAVInputOpenResponse(const proto::messages::AVInp
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendAVInputOpenResponse: %s", response.Utf8DebugString().c_str());

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC));
message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_INPUT_OPEN_RESPONSE).getData());
message->insertPayload(response);

Expand All @@ -97,7 +97,7 @@ void AVInputServiceChannel::sendAVMediaWithTimestampIndication(messenger::Timest
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendAVMediaWithTimestampIndication");

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC));
message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_MEDIA_WITH_TIMESTAMP_INDICATION).getData());

auto timestampData = messenger::Timestamp(timestamp).getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace channel
namespace av
{

class AVInputServiceChannel: public IAVInputServiceChannel, public ServiceChannel
class AVInputServiceChannel: public IAVInputServiceChannel, public ServiceChannel, public std::enable_shared_from_this<AVInputServiceChannel>
{
public:
AVInputServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger);
Expand All @@ -26,6 +26,7 @@ class AVInputServiceChannel: public IAVInputServiceChannel, public ServiceChanne
messenger::ChannelId getId() const override;

private:
using std::enable_shared_from_this<AVInputServiceChannel>::shared_from_this;
void messageHandler(messenger::Message::Pointer message, IAVInputServiceChannelEventHandler::Pointer eventHandler);
void handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler);
void handleAVInputOpenRequest(const common::DataConstBuffer& payload, IAVInputServiceChannelEventHandler::Pointer eventHandler);
Expand Down
45 changes: 40 additions & 5 deletions aasdk/src/main/cpp/libaasdk-jni/channel/av/AudioServiceChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AudioServiceChannel::AudioServiceChannel(boost::asio::io_service::strand& strand
void AudioServiceChannel::receive(IAudioServiceChannelEventHandler::Pointer eventHandler)
{
auto receivePromise = messenger::ReceivePromise::defer(strand_);
receivePromise->then(std::bind(&AudioServiceChannel::messageHandler, this, std::placeholders::_1, eventHandler),
receivePromise->then(std::bind(&AudioServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler),
std::bind(&IAudioServiceChannelEventHandler::onChannelError, eventHandler, std::placeholders::_1));

messenger_->enqueueReceive(channelId_, std::move(receivePromise));
Expand All @@ -35,7 +35,7 @@ void AudioServiceChannel::sendChannelOpenResponse(const proto::messages::Channel
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendChannelOpenResponse: %s", response.Utf8DebugString().c_str());

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL));
message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData());
message->insertPayload(response);

Expand All @@ -46,7 +46,7 @@ void AudioServiceChannel::sendAVChannelSetupResponse(const proto::messages::AVCh
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendAVChannelSetupResponse: %s", response.Utf8DebugString().c_str());

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC));
message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::SETUP_RESPONSE).getData());
message->insertPayload(response);

Expand All @@ -57,7 +57,7 @@ void AudioServiceChannel::sendAVMediaAckIndication(const proto::messages::AVMedi
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendAVMediaAckIndication: %s", indication.Utf8DebugString().c_str());

auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::SPECIFIC));
message->insertPayload(messenger::MessageId(proto::ids::AVChannelMessage::AV_MEDIA_ACK_INDICATION).getData());
message->insertPayload(indication);

Expand All @@ -83,9 +83,11 @@ void AudioServiceChannel::messageHandler(messenger::Message::Pointer message, IA
break;
case proto::ids::AVChannelMessage::AV_MEDIA_WITH_TIMESTAMP_INDICATION:
this->handleAVMediaWithTimestampIndication(payload, std::move(eventHandler));
// this->handleAVMediaWithTimestampIndication(std::move(message->getPayload()), std::move(eventHandler));
break;
case proto::ids::AVChannelMessage::AV_MEDIA_INDICATION:
eventHandler->onAVMediaIndication(payload);
// this->handleAVMediaIndication(std::move(message->getPayload()), std::move(eventHandler));
break;
case proto::ids::ControlMessage::CHANNEL_OPEN_REQUEST:
this->handleChannelOpenRequest(payload, std::move(eventHandler));
Expand Down Expand Up @@ -157,8 +159,9 @@ void AudioServiceChannel::handleAVMediaWithTimestampIndication(const common::Dat
{
if(payload.size >= sizeof(messenger::Timestamp::ValueType))
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("handleAVMediaWithTimestampIndication");
if (Log::isVerbose() && Log::logProtocol()) Log_v("handleAVMediaWithTimestampIndication %s", common::dump(payload).c_str());
messenger::Timestamp timestamp(payload);
if (Log::isVerbose()) Log_v("handleAVMediaWithTimestampIndication timestamp %lld", timestamp);
eventHandler->onAVMediaWithTimestampIndication(timestamp.getValue(), common::DataConstBuffer(payload.cdata, payload.size, sizeof(messenger::Timestamp::ValueType)));
}
else
Expand All @@ -167,6 +170,38 @@ void AudioServiceChannel::handleAVMediaWithTimestampIndication(const common::Dat
}
}

void AudioServiceChannel::handleAVMediaWithTimestampIndication(const common::Data payload, IAudioServiceChannelEventHandler::Pointer eventHandler)
{
if(payload.size() >= sizeof(messenger::Timestamp::ValueType))
{
eventHandler->onAVMediaWithTimestampIndication(std::move(payload));
}
else
{
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
}
}

//void AudioServiceChannel::handleAVMediaIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler)
//{
//// strand_.post([payload = std::move(payload), eventHandler = std::move(eventHandler)]() mutable {
//// if (Log::isVerbose() && Log::logProtocol()) Log_v("handleAVMediaIndication %s", common::dump(payload).c_str());
// eventHandler->onAVMediaIndication(payload);
//// });
//}

void AudioServiceChannel::handleAVMediaIndication(const common::Data payload, IAudioServiceChannelEventHandler::Pointer eventHandler)
{
if(payload.size() >= sizeof(messenger::Timestamp::ValueType))
{
eventHandler->onAVMediaIndication(std::move(payload));
}
else
{
eventHandler->onChannelError(error::Error(error::ErrorCode::PARSE_PAYLOAD));
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace channel
namespace av
{

class AudioServiceChannel: public IAudioServiceChannel, public ServiceChannel
class AudioServiceChannel: public IAudioServiceChannel, public ServiceChannel, public std::enable_shared_from_this<AudioServiceChannel>
{
public:
AudioServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger, messenger::ChannelId channelId);
Expand All @@ -24,12 +24,16 @@ class AudioServiceChannel: public IAudioServiceChannel, public ServiceChannel
messenger::ChannelId getId() const override;

private:
using std::enable_shared_from_this<AudioServiceChannel>::shared_from_this;
void messageHandler(messenger::Message::Pointer message, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleAVChannelSetupRequest(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleStartIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleStopIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleChannelOpenRequest(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleAVMediaWithTimestampIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleAVMediaWithTimestampIndication(const common::Data payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
// void handleAVMediaIndication(const common::DataConstBuffer& payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
void handleAVMediaIndication(const common::Data payload, IAudioServiceChannelEventHandler::Pointer eventHandler);
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace av
class IAVInputServiceChannel
{
public:
typedef IAVInputServiceChannel* Pointer;
typedef std::shared_ptr<IAVInputServiceChannel> Pointer;

IAVInputServiceChannel() = default;
virtual ~IAVInputServiceChannel() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace av
class IAVInputServiceChannelEventHandler
{
public:
typedef IAVInputServiceChannelEventHandler* Pointer;
typedef std::shared_ptr<IAVInputServiceChannelEventHandler> Pointer;

IAVInputServiceChannelEventHandler() = default;
virtual ~IAVInputServiceChannelEventHandler() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace av
class IAudioServiceChannel
{
public:
typedef IAudioServiceChannel* Pointer;
typedef std::shared_ptr<IAudioServiceChannel> Pointer;

IAudioServiceChannel() = default;
virtual ~IAudioServiceChannel() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace av
class IAudioServiceChannelEventHandler
{
public:
typedef IAudioServiceChannelEventHandler* Pointer;
typedef std::shared_ptr<IAudioServiceChannelEventHandler> Pointer;

IAudioServiceChannelEventHandler() = default;
virtual ~IAudioServiceChannelEventHandler() = default;
Expand All @@ -30,7 +30,9 @@ class IAudioServiceChannelEventHandler
virtual void onAVChannelStartIndication(const proto::messages::AVChannelStartIndication& indication) = 0;
virtual void onAVChannelStopIndication(const proto::messages::AVChannelStopIndication& indication) = 0;
virtual void onAVMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::DataConstBuffer& buffer) = 0;
virtual void onAVMediaWithTimestampIndication(const common::Data buffer) = 0;
virtual void onAVMediaIndication(const common::DataConstBuffer& buffer) = 0;
virtual void onAVMediaIndication(const common::Data buffer) = 0;
virtual void onChannelError(const error::Error& e) = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace av
class IMediaStatusServiceChannel
{
public:
typedef IMediaStatusServiceChannel* Pointer;
typedef std::shared_ptr<IMediaStatusServiceChannel> Pointer;

IMediaStatusServiceChannel() = default;
virtual ~IMediaStatusServiceChannel() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace av
class IMediaStatusServiceChannelEventHandler
{
public:
typedef IMediaStatusServiceChannelEventHandler* Pointer;
typedef std::shared_ptr<IMediaStatusServiceChannelEventHandler> Pointer;

IMediaStatusServiceChannelEventHandler() = default;
virtual ~IMediaStatusServiceChannelEventHandler() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace av
class IVideoServiceChannel
{
public:
typedef IVideoServiceChannel* Pointer;
typedef std::shared_ptr<IVideoServiceChannel> Pointer;

IVideoServiceChannel() = default;
virtual ~IVideoServiceChannel() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace av
class IVideoServiceChannelEventHandler
{
public:
typedef IVideoServiceChannelEventHandler* Pointer;
typedef std::shared_ptr<IVideoServiceChannelEventHandler> Pointer;

IVideoServiceChannelEventHandler() = default;
virtual ~IVideoServiceChannelEventHandler() = default;
Expand All @@ -30,7 +30,9 @@ class IVideoServiceChannelEventHandler
virtual void onAVChannelStartIndication(const proto::messages::AVChannelStartIndication& indication) = 0;
virtual void onAVChannelStopIndication(const proto::messages::AVChannelStopIndication& indication) = 0;
virtual void onAVMediaWithTimestampIndication(messenger::Timestamp::ValueType, const common::DataConstBuffer& buffer) = 0;
virtual void onAVMediaWithTimestampIndication(const common::Data buffer) = 0;
virtual void onAVMediaIndication(const common::DataConstBuffer& buffer) = 0;
virtual void onAVMediaIndication(const common::Data buffer) = 0;
virtual void onVideoFocusRequest(const proto::messages::VideoFocusRequest& request) = 0;
virtual void onChannelError(const error::Error& e) = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MediaStatusServiceChannel::MediaStatusServiceChannel(boost::asio::io_service::st
void MediaStatusServiceChannel::receive(IMediaStatusServiceChannelEventHandler::Pointer eventHandler)
{
auto receivePromise = messenger::ReceivePromise::defer(strand_);
receivePromise->then(std::bind(&MediaStatusServiceChannel::messageHandler, this, std::placeholders::_1, eventHandler),
receivePromise->then(std::bind(&MediaStatusServiceChannel::messageHandler, this->shared_from_this(), std::placeholders::_1, eventHandler),
std::bind(&IMediaStatusServiceChannelEventHandler::onChannelError, eventHandler,std::placeholders::_1));

messenger_->enqueueReceive(channelId_, std::move(receivePromise));
Expand All @@ -39,7 +39,7 @@ messenger::ChannelId MediaStatusServiceChannel::getId() const
void MediaStatusServiceChannel::sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise)
{
if (Log::isVerbose() && Log::logProtocol()) Log_v("sendChannelOpenResponse: %s", response.Utf8DebugString().c_str());
auto message = std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL);
auto message(std::make_shared<messenger::Message>(channelId_, messenger::EncryptionType::ENCRYPTED, messenger::MessageType::CONTROL));
message->insertPayload(messenger::MessageId(proto::ids::ControlMessage::CHANNEL_OPEN_RESPONSE).getData());
message->insertPayload(response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace channel
namespace av
{

class MediaStatusServiceChannel: public IMediaStatusServiceChannel, public ServiceChannel
class MediaStatusServiceChannel: public IMediaStatusServiceChannel, public ServiceChannel, public std::enable_shared_from_this<MediaStatusServiceChannel>
{
public:
MediaStatusServiceChannel(boost::asio::io_service::strand& strand, messenger::IMessenger::Pointer messenger);
Expand All @@ -21,6 +21,7 @@ class MediaStatusServiceChannel: public IMediaStatusServiceChannel, public Servi
void sendChannelOpenResponse(const proto::messages::ChannelOpenResponse& response, SendPromise::Pointer promise) override;

private:
using std::enable_shared_from_this<MediaStatusServiceChannel>::shared_from_this;
void messageHandler(messenger::Message::Pointer message, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
void handleChannelOpenRequest(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
void handleMetadataUpdate(const common::DataConstBuffer& payload, IMediaStatusServiceChannelEventHandler::Pointer eventHandler);
Expand Down
Loading

0 comments on commit 1003901

Please sign in to comment.