+#ifdef TV_BT_MODE
+static float get_volume_decibel(char* data, int size, stte_audio_type_e type);
+
+//static stt_recorder_s* __get_recorder(int engine_id);
+
+static int g_bt_extend_count;
+
+#define SMART_CONTROL_EXTEND_CMD 0x03
+#define SMART_CONTROL_START_CMD 0x04
+
+static void _bt_cb_hid_state_changed(int result, bool connected, const char *remote_address, void *user_data)
+{
+ SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Bluetooth Event [%d] Received address [%s]", result, remote_address);
+}
+
+static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void *user_data)
+{
+ if (STTD_RECORDER_STATE_RECORDING != g_recorder_state) {
+ /* SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Exit audio reading normal func"); */
+ return;
+ }
+
+ if (NULL != g_audio_cb) {
+ if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to read audio");
+ sttd_recorder_stop();
+ }
+
+ if (NULL == g_recorder) {
+ return;
+ }
+
+ float vol_db = get_volume_decibel((char*)voice_data->audio_buf, (int)voice_data->length, g_recorder->audio_type);
+ if (0 != sttdc_send_set_volume(g_recorder->uid, vol_db)) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Fail to send recording volume(%f)", vol_db);
+ }
+ }
+
+ if (0 == g_buffer_count || 0 == g_buffer_count % 50) {
+ SLOG(LOG_WARN, TAG_STTD, "[Recorder][%d] Recording... : read_size(%d)", g_buffer_count, voice_data->length);
+
+ if (0 == g_bt_extend_count % 5 && 0 != g_buffer_count) {
+ const unsigned char input_data[2] = {SMART_CONTROL_EXTEND_CMD, 0x10 };
+ if (BT_ERROR_NONE != bt_hid_send_rc_command(NULL, input_data, sizeof(input_data))) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail bt_hid_send_rc_command(NULL, %s, %d)", input_data, sizeof(input_data));
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Extend bt audio recorder");
+ }
+ }
+ g_bt_extend_count++;
+
+ if (100000 == g_buffer_count) {
+ g_buffer_count = 0;
+ }
+ }
+
+ g_buffer_count++;
+
+#ifdef BUF_SAVE_MODE
+ /* write pcm buffer */
+ fwrite(data, 1, len, g_pFile);
+#endif
+ return;
+}
+#endif
+
+