uint8_t a2dp_source_establish_stream(bd_addr_t remote_addr, uint8_t loc_seid, uint16_t * a2dp_cid){ sc.local_stream_endpoint = avdtp_stream_endpoint_for_seid(loc_seid, &a2dp_source_context); if (!sc.local_stream_endpoint){ log_error(" no local_stream_endpoint for seid %d", loc_seid); return AVDTP_SEID_DOES_NOT_EXIST; } memcpy(sc.remote_addr, remote_addr, 6); return avdtp_source_connect(remote_addr, a2dp_cid); }
static void stdin_process(char cmd){ uint8_t status = ERROR_CODE_SUCCESS; is_cmd_triggered_localy = 1; switch (cmd){ case 'c': printf("Establish AVDTP Source connection to %s\n", device_addr_string); status = avdtp_source_connect(device_addr, &media_tracker.avdtp_cid); break; case 'C': printf("Disconnect AVDTP Source\n"); status = avdtp_source_disconnect(media_tracker.avdtp_cid); break; case 'd': printf("Discover stream endpoints of %s\n", device_addr_string); status = avdtp_source_discover_stream_endpoints(media_tracker.avdtp_cid); break; case 'g': printf("Get capabilities of stream endpoint with seid %d\n", media_tracker.remote_seid); status = avdtp_source_get_capabilities(media_tracker.avdtp_cid, media_tracker.remote_seid); break; case 'a': printf("Get all capabilities of stream endpoint with seid %d\n", media_tracker.remote_seid); status = avdtp_source_get_all_capabilities(media_tracker.avdtp_cid, media_tracker.remote_seid); break; case 'f': printf("Get configuration of stream endpoint with seid %d\n", media_tracker.remote_seid); status = avdtp_source_get_configuration(media_tracker.avdtp_cid, media_tracker.remote_seid); break; case 's': printf("Set configuration of stream endpoint with seid %d\n", media_tracker.remote_seid); remote_configuration_bitmap = store_bit16(remote_configuration_bitmap, AVDTP_MEDIA_CODEC, 1); remote_configuration.media_codec.media_type = AVDTP_AUDIO; remote_configuration.media_codec.media_codec_type = AVDTP_CODEC_SBC; remote_configuration.media_codec.media_codec_information_len = sizeof(media_sbc_codec_configuration); remote_configuration.media_codec.media_codec_information = (uint8_t *)media_sbc_codec_configuration; initialize_streaming_context(media_sbc_codec_configuration); status = avdtp_source_set_configuration(media_tracker.avdtp_cid, media_tracker.local_seid, media_tracker.remote_seid, remote_configuration_bitmap, remote_configuration); break; case 'R': printf("Reconfigure stream endpoint with seid %d\n", media_tracker.remote_seid); remote_configuration_bitmap = store_bit16(remote_configuration_bitmap, AVDTP_MEDIA_CODEC, 1); remote_configuration.media_codec.media_type = AVDTP_AUDIO; remote_configuration.media_codec.media_codec_type = AVDTP_CODEC_SBC; remote_configuration.media_codec.media_codec_information_len = sizeof(media_sbc_codec_reconfiguration); remote_configuration.media_codec.media_codec_information = (uint8_t *)media_sbc_codec_reconfiguration; initialize_streaming_context(media_sbc_codec_reconfiguration); status = avdtp_source_reconfigure(media_tracker.avdtp_cid, media_tracker.local_seid, media_tracker.remote_seid, remote_configuration_bitmap, remote_configuration); break; case 'o': printf("Establish stream between local %d and remote %d seid\n", media_tracker.local_seid, media_tracker.remote_seid); initialize_sbc_encoder(); status = avdtp_source_open_stream(media_tracker.avdtp_cid, media_tracker.local_seid, media_tracker.remote_seid); break; case 'm': printf("Start stream between local %d and remote %d seid, \n", media_tracker.local_seid, media_tracker.remote_seid); status = avdtp_source_start_stream(media_tracker.avdtp_cid, media_tracker.local_seid); break; case 'A': printf("Abort stream between local %d and remote %d seid\n", media_tracker.local_seid, media_tracker.remote_seid); status = avdtp_source_abort_stream(media_tracker.avdtp_cid, media_tracker.local_seid); break; case 'S': printf("Release stream between local %d and remote %d seid\n", media_tracker.local_seid, media_tracker.remote_seid); status = avdtp_source_stop_stream(media_tracker.avdtp_cid, media_tracker.local_seid); break; case 'P': printf("Susspend stream between local %d and remote %d seid\n", media_tracker.local_seid, media_tracker.remote_seid); status = avdtp_source_suspend(media_tracker.avdtp_cid, media_tracker.local_seid); break; case 'X': printf("Stop streaming\n"); status = avdtp_source_stop_stream(media_tracker.avdtp_cid, media_tracker.local_seid); break; case '\n': case '\r': break; default: show_usage(); break; } if (status != ERROR_CODE_SUCCESS){ printf("AVDTP Sink cmd \'%c\' failed, status 0x%02x\n", cmd, status); } }