Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Version 0.4.1 alexa-client-sdk
Browse files Browse the repository at this point in the history
Changes in this update
-Implemented Sensory wake word detector functionality
-Removed the need for a std::recursive_mutex in MessageRouter
-Added AIP unit test
-Added handleDirectiveImmediately functionality to SpeechSynthesizer
-Added memory profiles for:
AIP
SpeechSynthesizer
ContextManager
AVSUtils
AVSCommon
-Bug fix for MultipartParser.h compiler warning
-Suppression of sensitive log data even in debug builds. Use cmake parameter -DACSDK_EMIT_SENSITIVE_LOGS=ON to allow logging of sensitive information in DEBUG builds
-Fix crash in ACL when attempting to use more than 10 streams
-Updated MediaPlayer to use autoaudiosink instead of requiring pulseaudio
-Updated MediaPlayer build to suppport local builds of GStreamer
-Fixes for the following Github issues:
#5
#8
#9
#10
#17
#24
  • Loading branch information
Keith Huang committed Jun 9, 2017
1 parent 8ada36d commit c84d60c
Show file tree
Hide file tree
Showing 119 changed files with 4,012 additions and 1,590 deletions.
5 changes: 2 additions & 3 deletions ACL/include/ACL/AVSConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <AVSCommon/SDKInterfaces/MessageObserverInterface.h>
#include <AVSCommon/SDKInterfaces/MessageSenderInterface.h>

#include "ACL/Values.h"
#include "ACL/AuthDelegateInterface.h"
#include "ACL/ConnectionStatusObserverInterface.h"
#include "ACL/Transport/MessageRouterInterface.h"
Expand Down Expand Up @@ -135,8 +134,8 @@ class AVSConnectionManager :
std::shared_ptr<ConnectionStatusObserverInterface> connectionStatusObserver = nullptr,
std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> messageObserver = nullptr);

void onConnectionStatusChanged(const ConnectionStatus status,
const ConnectionChangedReason reason) override;
void onConnectionStatusChanged(const ConnectionStatusObserverInterface::Status status,
const ConnectionStatusObserverInterface::ChangedReason reason) override;

void receive(const std::string & contextId, const std::string & message) override;

Expand Down
70 changes: 66 additions & 4 deletions ACL/include/ACL/ConnectionStatusObserverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#ifndef ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_CONNECTION_STATUS_OBSERVER_INTERFACE_H_
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_CONNECTION_STATUS_OBSERVER_INTERFACE_H_

#include "ACL/Values.h"

namespace alexaClientSDK {
namespace acl {

Expand All @@ -28,6 +26,70 @@ namespace acl {
*/
class ConnectionStatusObserverInterface {
public:

/**
* This enum expresses the states that a logical AVS connection can be in.
*/
enum class Status {

/// ACL is not connected to AVS.
DISCONNECTED,

/// ACL is attempting to establish a connection to AVS.
PENDING,

/// ACL is connected to AVS.
CONNECTED
};

/**
* This enum expresses the reasons a connection status may change.
*/
enum class ChangedReason {

/// The connection status changed due to the client interacting with the Connection public api.
ACL_CLIENT_REQUEST,

/// The connection attempt failed due to the Connection object being disabled.
ACL_DISABLED,

/// The connection attempt failed due to DNS resolution timeout.
DNS_TIMEDOUT,

/// The connection attempt failed due to timeout.
CONNECTION_TIMEDOUT,

/// The connection attempt failed due to excessive load on the server.
CONNECTION_THROTTLED,

/// The access credentials provided to ACL were invalid.
INVALID_AUTH,

/// There was a timeout sending a ping request.
PING_TIMEDOUT,

/// There was a timeout writing to AVS.
WRITE_TIMEDOUT,

/// There was a timeout reading from AVS.
READ_TIMEDOUT,

/// There was an underlying protocol error.
FAILURE_PROTOCOL_ERROR,

/// There was an internal error within ACL.
INTERNAL_ERROR,

/// There was an internal error on the server.
SERVER_INTERNAL_ERROR,

/// The server asked the client to reconnect.
SERVER_SIDE_DISCONNECT,

/// The server endpoint has changed.
SERVER_ENDPOINT_CHANGED
};

/**
* Destructor.
*/
Expand All @@ -38,8 +100,8 @@ class ConnectionStatusObserverInterface {
* @status The current connection status.
* @reason The reason the status change occurred.
*/
virtual void onConnectionStatusChanged(const ConnectionStatus status,
const ConnectionChangedReason reason) = 0;
virtual void onConnectionStatusChanged(const Status status,
const ChangedReason reason) = 0;
};

} // namespace acl
Expand Down
69 changes: 69 additions & 0 deletions ACL/include/ACL/EnumUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* EnumUtils.h
*
* Copyright 2016-2017 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file 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.
*/

#ifndef ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_ENUM_UTILS_H_
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_ENUM_UTILS_H_


#include <ostream>
#include <string>
#include "ACL/ConnectionStatusObserverInterface.h"

namespace alexaClientSDK {
namespace acl {

/**
* Utility function to convert a modern enum class to a string.
*
* @param status The enum value
* @return The string representation of the incoming value.
*/
std::string connectionStatusToString(ConnectionStatusObserverInterface::Status status);

/**
* Utility function to convert a modern enum class to a string.
*
* @param status The enum value
* @return The string representation of the incoming value.
*/
std::string connectionChangedReasonToString(ConnectionStatusObserverInterface::ChangedReason reason);

/**
* Write a @c Status value to an @c ostream as a string.
*
* @param stream The stream to write the value to.
* @param status The Status value to write to the @c ostream as a string.
* @return The @c ostream that was passed in and written to.
*/
inline std::ostream& operator << (std::ostream& stream, ConnectionStatusObserverInterface::Status status) {
return stream << connectionStatusToString(status);
}

/**
* Write a @c ChangedReason value to an @c ostream as a string.
*
* @param stream The stream to write the value to.
* @param reason The ChangedReason value to write to the @c ostream as a string.
* @return The @c ostream that was passed in and written to.
*/
inline std::ostream& operator << (std::ostream& stream, ConnectionStatusObserverInterface::ChangedReason reason) {
return stream << connectionChangedReasonToString(reason);
}

} // namespace acl
} // namespace alexaClientSDK
#endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_ENUM_UTILS_H_
61 changes: 42 additions & 19 deletions ACL/include/ACL/Transport/MessageRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MessageRouter: public MessageRouterInterface, public TransportObserverInte

void disable() override;

ConnectionStatus getConnectionStatus() override;
ConnectionStatusObserverInterface::Status getConnectionStatus() override;

void send(std::shared_ptr<avsCommon::avs::MessageRequest> request) override;

Expand All @@ -82,7 +82,7 @@ class MessageRouter: public MessageRouterInterface, public TransportObserverInte

void onConnected() override;

void onDisconnected(ConnectionChangedReason reason) override;
void onDisconnected(ConnectionStatusObserverInterface::ChangedReason reason) override;

void onServerSideDisconnect() override;

Expand All @@ -107,6 +107,17 @@ class MessageRouter: public MessageRouterInterface, public TransportObserverInte
MessageConsumerInterface* messageConsumerInterface,
TransportObserverInterface* transportObserverInterface) = 0;

/**
* Set the connection state. If it changes, notify our observer.
* @c m_connectionMutex must be locked to call this method.
*
* @param status The current status of the connection.
* @param reason The reason the connection status changed.
*/
void setConnectionStatusLocked(
const ConnectionStatusObserverInterface::Status status,
const ConnectionStatusObserverInterface::ChangedReason reason);

/**
* Notify the connection observer when the status has changed.
* Architectural note:
Expand All @@ -117,7 +128,9 @@ class MessageRouter: public MessageRouterInterface, public TransportObserverInte
* @param status The current status of the connection.
* @param reason The reason the connection status changed.
*/
void notifyObserverOnConnectionStatusChanged(const ConnectionStatus status, const ConnectionChangedReason reason);
void notifyObserverOnConnectionStatusChanged(
const ConnectionStatusObserverInterface::Status status,
const ConnectionStatusObserverInterface::ChangedReason reason);

/**
* Notify the message observer of an incoming message from AVS.
Expand All @@ -133,43 +146,53 @@ class MessageRouter: public MessageRouterInterface, public TransportObserverInte

/**
* Creates a new transport, and begins the connection process. The new transport immediately becomes the active
* transport. The connection mutex must be locked to call this method.
* transport. @c m_connectionMutex must be locked to call this method.
*/
void createActiveTransportLocked();

/**
* Disconnects all transports. The connection mutex must be locked to call this method.
* Disconnects all transports. @c m_connectionMutex must be locked to call this method.
*
* @param reason The reason the last transport was disconnected
* @param lock Reference to the @c unique_lock that must be held when this method is called. The lock may be
* released during the execution of this method, but will be locked when this method exits.
*/
void disconnectAllTransportsLocked(
std::unique_lock<std::mutex>& lock,
const ConnectionStatusObserverInterface::ChangedReason reason);

/**
* Get the observer.
*
* @return The observer.
*/
void disconnectAllTransportsLocked(const ConnectionChangedReason reason);
std::shared_ptr<MessageRouterObserverInterface> getObserver();

/// The observer object.
/// The observer object. Access serialized with @c m_connectionMutex.
std::shared_ptr<MessageRouterObserverInterface> m_observer;

/// The current AVS endpoint
/// The current AVS endpoint. Access serialized with @c m_connectionMutex.
std::string m_avsEndpoint;

/// The AuthDelegateInterface which provides a valid access token.
std::shared_ptr<AuthDelegateInterface> m_authDelegate;

/*
* This mutex guards access to all connection related state, specifically the status and all transport interaction.
*
* TODO: ACSDK-98 Remove the requirement for this to be a recursive mutex.
*/
std::recursive_mutex m_connectionMutex;
/// This mutex guards access to all connection related state, specifically the status and all transport interaction.
std::mutex m_connectionMutex;

/// The current connection status.
ConnectionStatus m_connectionStatus;
/// The current connection status. Access serialized with @c m_connectionMutex.
ConnectionStatusObserverInterface::Status m_connectionStatus;

/// When the MessageRouter is enabled, any disconnect should automatically trigger a reconnect with AVS.
/**
* When the MessageRouter is enabled, any disconnect should automatically trigger a reconnect with AVS.
* Access serialized with @c m_connectionMutex.
*/
bool m_isEnabled;

/// A list of all transports which are not disconnected.
/// A vector of all transports which are not disconnected. Access serialized with @c m_connectionMutex.
std::vector<std::shared_ptr<TransportInterface>> m_transports;

/// The current active transport to send messages on.
/// The current active transport to send messages on. Access serialized with @c m_connectionMutex.
std::shared_ptr<TransportInterface> m_activeTransport;

/// Executor to execute sending any messages to AVS.
Expand Down
2 changes: 1 addition & 1 deletion ACL/include/ACL/Transport/MessageRouterInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MessageRouterInterface {
* Queries the status of the connection.
* @return Returns the connection status of the underlying implementation.
*/
virtual ConnectionStatus getConnectionStatus() = 0;
virtual ConnectionStatusObserverInterface::Status getConnectionStatus() = 0;

/**
* Send a message to AVS.
Expand Down
7 changes: 3 additions & 4 deletions ACL/include/ACL/Transport/MessageRouterObserverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGE_ROUTER_OBSERVER_INTERFACE_H_

#include <memory>

#include "ACL/Values.h"
#include "ACL/ConnectionStatusObserverInterface.h"

namespace alexaClientSDK {
namespace acl {
Expand All @@ -39,8 +38,8 @@ class MessageRouterObserverInterface {
* @param status The current status of the connection.
* @param reason The reason the connection status changed.
*/
virtual void onConnectionStatusChanged(const ConnectionStatus status,
const ConnectionChangedReason reason) = 0;
virtual void onConnectionStatusChanged(const ConnectionStatusObserverInterface::Status status,
const ConnectionStatusObserverInterface::ChangedReason reason) = 0;

/**
* This function will be called when a Message arrives from AVS.
Expand Down
5 changes: 2 additions & 3 deletions ACL/include/ACL/Transport/TransportObserverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_TRANSPORT_OBSERVER_INTERFACE_H_

#include <memory>

#include "ACL/Values.h"
#include "ACL/ConnectionStatusObserverInterface.h"

namespace alexaClientSDK {
namespace acl {
Expand All @@ -44,7 +43,7 @@ class TransportObserverInterface {
* Called when we disconnect from AVS.
* @param reason The reason that we disconnected.
*/
virtual void onDisconnected(ConnectionChangedReason reason) = 0;
virtual void onDisconnected(ConnectionStatusObserverInterface::ChangedReason reason) = 0;

/**
* Called when the server asks the client to reconnect
Expand Down
Loading

0 comments on commit c84d60c

Please sign in to comment.