SPICE协议支持服务器发送音频流数据在客户端播放。音频流服务器使用SPICE_MSG_PLAYBACK_DATA消息发送客户端,音频数据的内容有播放模式控制(服务器通过SPICE_MSG_PLAYBACK_MODE消息发送客户端)。服务器通过发送SPICE_MSG_PLAYBACK_START消息和SPICE_MSG_PLAYBACK_STOP消息来停止和播放音频流。数据包发送期间只允许停止和播放消息。
enum {
SPICE_MSG_PLAYBACK_DATA = 101,
SPICE_MSG_PLAYBACK_MODE,
SPICE_MSG_PLAYBACK_START,
SPICE_MSG_PLAYBACK_STOP,
SPICE_MSG_PLAYBACK_VOLUME,
SPICE_MSG_PLAYBACK_MUTE,
SPICE_MSG_PLAYBACK_LATENCY,
SPICE_MSG_END_PLAYBACK
};
typedef enumSpiceAudioFmt {
SPICE_AUDIO_FMT_INVALID,
SPICE_AUDIO_FMT_S16,
SPICE_AUDIO_FMT_ENUM_END
}SpiceAudioFmt;
typedef enumSpiceAudioDataMode {
SPICE_AUDIO_DATA_MODE_INVALID,
SPICE_AUDIO_DATA_MODE_RAW,
SPICE_AUDIO_DATA_MODE_CELT_0_5_1,
SPICE_AUDIO_DATA_MODE_OPUS,
SPICE_AUDIO_DATA_MODE_ENUM_END
}SpiceAudioDataMode;
SPICE客户机需要声明支持CELT_5_1通道功能,以允许服务器发送播放CELT_0_5_1格式的数据包。这个应该在通道建立的时候会有能力协商吧?
typedef struct SpiceMsgPlaybackStart {
uint32_t channels;
uint32_t format; //SPICE_AUDIO_FMT_?
uint32_t frequency;
uint32_t time;
} SpiceMsgPlaybackStart;
SPICE协议支持音频流捕捉从客户端发送到服务器。SPCIE服务器发送SPICE_MSG_RECORD_START通知客户端开始发送音频数据。客户端回应开始发送开始标记时间戳(REDC_RECORD_START_MARK)客户端发送完开始标记后使用SPICE_MSGC_RECORD_DATA。为了通知服务器使用什么样的类型发送数据,在发送时间戳之前必须发送SPICE_MSGC_RECORD_MODE消息。服务器发送SPICE_MSG_RECORD_STOP消息通知客户端停止。
enum {
SPICE_MSG_RECORD_START = 101,
SPICE_MSG_RECORD_STOP,
SPICE_MSG_RECORD_VOLUME,
SPICE_MSG_RECORD_MUTE,
SPICE_MSG_END_RECORD
};
enum {
SPICE_MSGC_RECORD_DATA = 101,
SPICE_MSGC_RECORD_MODE,
SPICE_MSGC_RECORD_START_MARK,
SPICE_MSGC_END_RECORD
};
typedef enumSpiceAudioFmt {
SPICE_AUDIO_FMT_INVALID,
SPICE_AUDIO_FMT_S16,
SPICE_AUDIO_FMT_ENUM_END
} SpiceAudioFmt;
两种类型的数据模式可供选择:
1) 原始数据PCM数据RAW格式
2) 压缩数据Celti_0_5_1格式
typedef enumSpiceAudioDataMode {
SPICE_AUDIO_DATA_MODE_INVALID,
SPICE_AUDIO_DATA_MODE_RAW,
SPICE_AUDIO_DATA_MODE_CELT_0_5_1,
SPICE_AUDIO_DATA_MODE_OPUS,
SPICE_AUDIO_DATA_MODE_ENUM_END
}SpiceAudioDataMode;
SPICE服务器需要声明支持CELT_5_1通道功能,以允许客户端发送记录CELT_0_5_1格式的数据包。
enum {
SPICE_RECORD_CAP_CELT_0_5_1,
SPICE_RECORD_CAP_VOLUME,
SPICE_RECORD_CAP_OPUS,
};
typedef structSpiceMsgPlaybackMode {
uint32_t time; //客户端时间戳
uint32_t mode; //SPICE_AUDIO_DATA_MODE_?
uint8_t *data;//数据
uint32_t data_size;.// 数据大小
} SpiceMsgPlaybackMode,SpiceMsgcRecordMode;
typedef structSpiceMsgRecordStart {
uint32_t channels;
uint32_t format; //SPICE_AUDIO_FMT_?
uint32_t frequency;
}SpiceMsgRecordStart;
typedef structSpiceMsgcRecordStartMark {
uint32_t time; //音频流开始时间戳
}SpiceMsgcRecordStartMark;
typedef structSpiceMsgPlaybackPacket {
uint32_t time; //时间戳
uint8_t *data;
uint32_t data_size;
}SpiceMsgPlaybackPacket, SpiceMsgcRecordPacket;