Skip to content

Commit

Permalink
Merge branch 'master' into development/locationsync-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
VeithMetro authored Jan 30, 2025
2 parents 7fe448c + e9f5754 commit 0b1c059
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 71 deletions.
132 changes: 132 additions & 0 deletions interfaces/IAudioStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2025 Metrological
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.
*/
#pragma once

#include "Module.h"

namespace Thunder {
namespace Exchange {

/* @json 1.0.0 @text:legacy_lowercase */
struct EXTERNAL IAudioStream : virtual public Core::IUnknown {

enum { ID = ID_AUDIOSTREAM };

enum codectype : uint16_t {
PCM = 1 /* @text:PCM */,
IMA_ADPCM = 2 /* @text:IMA-ADPCM */,

_ /* @end */,
ADPCM = IMA_ADPCM
};

struct audioprofile {
// Samples are always little endian signed integers

codectype codec /* @brief Compression method (PCM: uncompressed) */;
Core::OptionalType<string> codecParams /* @opaque @brief Additional parameters for codec */;
uint8_t channels /* @brief Number of audio channels (e.g. 1) */;
uint8_t resolution /* @brief Sample resultion in bits (e.g. 16) */;
uint32_t sampleRate /* @brief Sample rate in hertz (e.g. 16000) */;
Core::OptionalType<uint32_t> bitRate /* @brief Data rate of the compressed stream in bits per second (e.g. 64000) */;
};

enum streamstate : uint8_t {
UNAVAILABLE,
IDLE,
STARTED
};

// @event
struct INotification : virtual public Core::IUnknown {

enum { ID = ID_AUDIOSTREAM_NOTIFICATION };

// @statuslistener
// @text audiotransmission
// @brief Signals state of the stream
// @param state New state of the stream
// @param profile Details on the format used in the stream
virtual void StateChanged(const streamstate state, const Core::OptionalType<audioprofile>& profile) = 0;
};

// @event
struct ICallback : virtual public Core::IUnknown {

enum { ID = ID_AUDIOSTREAM_CALLBACK };

// @brief Provides audio data
// @text audioframe
// @param seq Frame number in current transmission (e.g. 1)
// @param timestamp Timestamp of the frame
// @param length Size of the raw data frame in bytes (e.g. 400)
// @param data Raw audio data, the format of the data is specified in the most recent *audiotransmission* notification
virtual void Data(const Core::OptionalType<uint16_t>& seq, const Core::OptionalType<uint32_t>& timestamp,
const uint16_t length, const uint8_t data[] /* @length:length @encode:base64 */) = 0;
};

virtual Core::hresult Register(INotification* const notification) = 0;
virtual Core::hresult Unregister(const INotification* const notification) = 0;

// Note: Installing a callback and registering for a JSON-RPC "audioframe" notification is mutually exclusive.
virtual Core::hresult Callback(ICallback* const callback) = 0;

// @property
// @brief Name of the stream
// @retval ERROR_ILLEGAL_STATE The stream is not ready for this operation
virtual Core::hresult Name(string& name /* @out */) const = 0;

// @property
// @brief Current state of the stream
virtual Core::hresult State(streamstate& state /* @out */) const = 0;

// @property
// @brief List of codecs supported by the stream
// @retval ERROR_ILLEGAL_STATE The stream is not ready for this operation
virtual Core::hresult Capabilities(codectype& caps /* @out @encode:bitmask */) const = 0;

// @property
// @text audioprofile
// @brief Preferred profile of the stream
// @retval ERROR_NOT_SUPPORTED Profile change is not supported by this stream
// @retval ERROR_ILLEGAL_STATE The stream is not ready for this operation
// @retval ERROR_BAD_REQUEST The profile specified is invalid
// @retval ERROR_INPROGRESS Stream is started, profile will be changed for the next streaming
virtual Core::hresult Profile(const audioprofile& profile) = 0;
virtual Core::hresult Profile(audioprofile& profile /* @out */) const = 0;

// @property
// @brief Stream position
// @description Current time in stream in milliseconds
// @retval ERROR_NOT_SUPPORTED Time reporting is not supported by this stream
// @retval ERROR_ILLEGAL_STATE The stream is not ready for this operation
virtual Core::hresult Time(uint32_t& time /* @out */) const = 0;

// @property
// @brief Stream speed
// @description Current stream speed in percent (0 - pause, 100 - play forward)
// @retval ERROR_NOT_SUPPORTED Speed setting is not supported by this stream
// @retval ERROR_ILLEGAL_STATE The stream is not ready for this operation
virtual Core::hresult Speed(const uint8_t speed) = 0;
virtual Core::hresult Speed(uint8_t& speed /* @out */) const = 0;
};


} // namespace Thunder
}
65 changes: 1 addition & 64 deletions interfaces/IBluetoothRemoteControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ namespace Exchange {
Core::OptionalType<string> manufacturer /* @brief Vendor/manufacturer name */;
};

enum codectype : uint8_t {
PCM /* @text:pcm */,
IMA_ADPCM /* @text:ima-adpcm */
};

struct audioprofile {
// Samples are always little endian signed integers
codectype codec /* @brief Compression method (pcm: uncompressed) */;
uint8_t channels /* @brief Number of audio channels (e.g. 1) */;
uint8_t resolution /* @brief Sample resultion in bits (e.g. 16) */;
uint32_t sampleRate /* @brief Sample rate in hertz (e.g. 16000) */;
};

// @event
struct INotification : virtual public Core::IUnknown {

Expand All @@ -63,38 +50,9 @@ namespace Exchange {
virtual void BatteryLevelChange(const uint8_t level) = 0;
};

// @event
struct IAudioTransmissionCallback : virtual public Core::IUnknown {

enum { ID = ID_BLUETOOTHREMOTECONTROL_CALLBACK };

enum transmissionstate : uint8_t {
STOPPED,
STARTED
};

// @statuslistener
// @text audiotransmission
// @brief Signals beginning end of audio transmission
// @param state New state of the voice transmission
// @param profile Details of the audio format used in the voice transmission
virtual void StateChanged(const transmissionstate state) = 0;

// @text audioframe
// @brief Provides audio frame data
// @description Format of the data can be retrieved with AudioProfile call
// @param seq Frame number in current transmission (e.g. 1)
// @param size Size of the raw data frame in bytes (e.g. 400)
// @param data Raw audio data
virtual void Data(const uint16_t seq, const uint16_t size, const uint8_t data[] /* @length:size @encode:base64 */) = 0;
};

virtual Core::hresult Register(INotification* const notification) = 0;
virtual Core::hresult Unregister(const INotification* const notification) = 0;

// Note: Installing a callback and registering for a JSON-RPC notification is mutually exclusive.
virtual Core::hresult Callback(IAudioTransmissionCallback* const callback) = 0;

// @brief Assigns a Bluetooth device as a RCU
// @param address: Address of the Bluetooth device to assign
// @retval ERROR_UNKNOWN_KEY Device address value is invalid
Expand All @@ -112,8 +70,8 @@ namespace Exchange {
virtual Core::hresult Device(string& address /* @out */) const = 0;

// @property
// @brief Device metadata
// @alt-deprecated:info
// @brief Device metadata
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult Metadata(unitmetadata& info /* @out */) const = 0;

Expand All @@ -130,29 +88,8 @@ namespace Exchange {
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult VoiceControl(bool& value /* @out */) const = 0;
virtual Core::hresult VoiceControl(const bool value) = 0;

// @property
// @brief Details of used audio format
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
// @retval ERROR_NOT_SUPPORTED The device does not support voice input
virtual Core::hresult AudioProfile(audioprofile& profile /* @out */) const = 0;
};

namespace JSONRPC {

// @json 1.0.0 @text:legacy_lowercase
struct IBluetoothRemoteControlLegacy {

virtual ~IBluetoothRemoteControlLegacy() = default;

// @property @deprecated
// @brief Name of the RCU device
// @retval ERROR_ILLEGAL_STATE The RCU device is not assigned
virtual Core::hresult Name(string& name /* @out */) const = 0;
};

}

} // namespace Exchange

}
2 changes: 1 addition & 1 deletion interfaces/IContentProtection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2022 Metrological
* Copyright 2022 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
67 changes: 67 additions & 0 deletions interfaces/IVoiceHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 Metrological
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.
*/

#pragma once
#include "Module.h"

#include "IAudioStream.h"
// @insert "IAudioStream.h"

namespace Thunder {
namespace Exchange {

struct EXTERNAL IVoiceHandler;

// This API is deprecated in favour of IAudioStream

/*
* Interface responsible for producing audio data
* The data that is produced must be signed little endian
*/
struct EXTERNAL IVoiceProducer : virtual public Core::IUnknown {
enum { ID = ID_VOICEPRODUCER };

struct EXTERNAL IProfile : virtual public Core::IUnknown {
enum { ID = ID_VOICEPRODUCER_PROFILE };

using codec = Exchange::IAudioStream::codectype;

virtual codec Codec() const = 0;
virtual uint8_t Channels() const = 0;
virtual uint32_t SampleRate() const = 0;
virtual uint8_t Resolution() const = 0;
};

virtual string Name() const = 0;
virtual uint32_t Callback(IVoiceHandler* callback) = 0;
virtual uint32_t Error() const = 0;
virtual string MetaData() const = 0;
virtual void Configure(const string& settings) = 0;
};

struct EXTERNAL IVoiceHandler : virtual public Core::IUnknown {
enum { ID = ID_VOICEHANDLER };

virtual void Start(const IVoiceProducer::IProfile* profile) = 0;
virtual void Stop() = 0;
virtual void Data(const uint32_t sequenceNo, const uint8_t data[] /* @length:length */, const uint16_t length) = 0;
};

} // Exchange
} // Thunder
17 changes: 11 additions & 6 deletions interfaces/Ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ namespace Exchange {
ID_GUIDE = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x0F0,
ID_GUIDE_NOTIFICATION = ID_GUIDE + 1,

ID_BLUETOOTHREMOTECONTROL = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x100,
ID_BLUETOOTHREMOTECONTROL_CALLBACK = ID_BLUETOOTHREMOTECONTROL + 1,
ID_BLUETOOTHREMOTECONTROL_NOTIFICATION = ID_BLUETOOTHREMOTECONTROL + 2,
ID_VOICEHANDLER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x100,
ID_VOICEPRODUCER = ID_VOICEHANDLER + 1,
ID_AUDIOSTREAM = ID_VOICEHANDLER + 2,
ID_AUDIOSTREAM_CALLBACK = ID_VOICEHANDLER + 3,
ID_AUDIOSTREAM_NOTIFICATION = ID_VOICEHANDLER + 4,

ID_WEBDRIVER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x110,

Expand Down Expand Up @@ -387,9 +389,12 @@ namespace Exchange {

ID_SYSTEMAUDIOPLAYER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x520,
ID_SYSTEMAUDIOPLAYER_NOTIFICATION = ID_SYSTEMAUDIOPLAYER + 1,

ID_LOCATIONSYNC = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x530,
ID_LOCATIONSYNC_NOTIFICATION = ID_LOCATIONSYNC + 1,

ID_BLUETOOTHREMOTECONTROL = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x530,
ID_BLUETOOTHREMOTECONTROL_NOTIFICATION = ID_BLUETOOTHREMOTECONTROL + 1,

ID_LOCATIONSYNC = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x540,
ID_LOCATIONSYNC_NOTIFICATION = ID_LOCATIONSYNC + 1
};
}
}

0 comments on commit 0b1c059

Please sign in to comment.