Update SigComp support and add WaveAPI producer.
This commit is contained in:
parent
2e16bbb884
commit
b69d248f04
|
@ -67,7 +67,7 @@ int tdav_consumer_audio_cmp(const tsk_object_t* consumer1, const tsk_object_t* c
|
|||
#define tdav_consumer_audio_consume(self, buffer, size) tmedia_consumer_consume(TDAV_CONSUMER_AUDIO(self), buffer, size)
|
||||
#define tdav_consumer_audio_pause(self) tmedia_consumer_pause(TDAV_CONSUMER_AUDIO(self))
|
||||
#define tdav_consumer_audio_stop(self) tmedia_consumer_stop(TDAV_CONSUMER_AUDIO(self))
|
||||
int tdav_consumer_audio_put(tdav_consumer_audio_t* self, void** data);
|
||||
int tdav_consumer_audio_put(tdav_consumer_audio_t* self, void** data, const tsk_object_t* proto_hdr);
|
||||
void* tdav_consumer_audio_get(tdav_consumer_audio_t* self);
|
||||
int tdav_consumer_audio_deinit(tdav_consumer_audio_t* self);
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ TDAV_BEGIN_DECLS
|
|||
|
||||
#define TDAV_BITS_PER_SAMPLE_DEFAULT 16
|
||||
|
||||
#define TDAV_PRODUCER_AUDIO(self) ((tdav_producer_audio_t*)(self))
|
||||
|
||||
typedef struct tdav_producer_audio_s
|
||||
{
|
||||
TMEDIA_DECLARE_PRODUCER;
|
||||
|
@ -45,17 +47,21 @@ typedef struct tdav_producer_audio_s
|
|||
uint8_t channels;
|
||||
uint32_t rate;
|
||||
uint8_t bits_per_sample;
|
||||
uint8_t ptime;
|
||||
}
|
||||
tdav_producer_audio_t;
|
||||
|
||||
int tdav_producer_audio_init(tdav_producer_audio_t* self);
|
||||
int tdav_producer_audio_prepare(tdav_producer_audio_t *self);
|
||||
int tdav_producer_audio_start(tdav_producer_audio_t *self);
|
||||
int tdav_producer_audio_consume(tdav_producer_audio_t* self, const void* buffer, tsk_size_t size);
|
||||
int tdav_producer_audio_pause(tdav_producer_audio_t *self);
|
||||
int tdav_producer_audio_stop(tdav_producer_audio_t *self);
|
||||
int tdav_producer_audio_cmp(const tsk_object_t* producer1, const tsk_object_t* producer2);
|
||||
#define tdav_producer_audio_prepare(self, codec) tmedia_producer_prepare(TMEDIA_PRODUCER(self), codec)
|
||||
#define tmedia_producer_audio_set_callback(self, callback, callback_data) tmedia_producer_set_callback(TMEDIA_PRODUCER(self), callback, callback_data)
|
||||
#define tdav_producer_audio_start(self) tdav_producer_start(TMEDIA_PRODUCER(self))
|
||||
#define tdav_producer_audio_pause(self) tdav_producer_pause(TMEDIA_PRODUCER(self))
|
||||
#define tdav_producer_audio_stop(self) tdav_producer_stop(TMEDIA_PRODUCER(self))
|
||||
int tdav_producer_audio_deinit(tdav_producer_audio_t* self);
|
||||
|
||||
#define TDAV_DECLARE_PRODUCER_AUDIO tdav_producer_audio_t __producer_audio__
|
||||
|
||||
TDAV_END_DECLS
|
||||
|
||||
#endif /* TINYDAV_PRODUCER_AUDIO_H */
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef struct tdav_session_audio_s
|
|||
struct trtp_manager_s* rtp_manager;
|
||||
|
||||
struct tmedia_consumer_s* consumer;
|
||||
struct tmedia_producer_s* producer;
|
||||
}
|
||||
tdav_session_audio_t;
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tdav_producer_waveapi.h
|
||||
* @brief Audio Consumer for Win32 and WinCE platforms.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)doubango.org>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#ifndef TINYDAV_PRODUCER_WAVEAPI_H
|
||||
#define TINYDAV_PRODUCER_WAVEAPI_H
|
||||
|
||||
#include "tinydav_config.h"
|
||||
|
||||
#if HAVE_WAVE_API
|
||||
|
||||
#include "tinydav/audio/tdav_producer_audio.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
TDAV_BEGIN_DECLS
|
||||
|
||||
#define TDAV_WAVEAPI_PRODUCER_NOTIF_POS_COUNT 4
|
||||
|
||||
typedef struct tdav_producer_waveapi_s
|
||||
{
|
||||
TDAV_DECLARE_PRODUCER_AUDIO;
|
||||
|
||||
tsk_bool_t started;
|
||||
|
||||
WAVEFORMATEX wfx;
|
||||
HWAVEIN hWaveIn;
|
||||
LPWAVEHDR hWaveHeaders[TDAV_WAVEAPI_PRODUCER_NOTIF_POS_COUNT];
|
||||
tsk_size_t bytes_per_notif;
|
||||
|
||||
void* tid[1];
|
||||
HANDLE events[2];
|
||||
CRITICAL_SECTION cs;
|
||||
}
|
||||
tdav_producer_waveapi_t;
|
||||
|
||||
TINYDAV_GEXTERN const tmedia_producer_plugin_def_t *tmedia_producer_waveapi_plugin_def_t;
|
||||
|
||||
TDAV_END_DECLS
|
||||
|
||||
#endif /* HAVE_WAVE_API */
|
||||
|
||||
#endif /* TINYDAV_PRODUCER_WAVEAPI_H */
|
|
@ -29,6 +29,8 @@
|
|||
*/
|
||||
#include "tinydav/audio/tdav_consumer_audio.h"
|
||||
|
||||
#include "tinyrtp/rtp/trtp_rtp_header.h"
|
||||
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_time.h"
|
||||
#include "tsk_debug.h"
|
||||
|
@ -84,18 +86,17 @@ int tdav_consumer_audio_cmp(const tsk_object_t* consumer1, const tsk_object_t* c
|
|||
}
|
||||
|
||||
/* put data into the jitter buffer */
|
||||
int tdav_consumer_audio_put(tdav_consumer_audio_t* self, void** data)
|
||||
int tdav_consumer_audio_put(tdav_consumer_audio_t* self, void** data, const tsk_object_t* proto_hdr)
|
||||
{
|
||||
static long ts = 0; /* FIXME: should come from the the RTP header */
|
||||
const trtp_rtp_header_t* rtp_hdr = (const trtp_rtp_header_t*)proto_hdr;
|
||||
|
||||
if(!self || !data || !*data || !self->jb.jbuffer){
|
||||
if(!self || !data || !*data || !self->jb.jbuffer || !rtp_hdr){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsk_safeobj_lock(self);
|
||||
ts += /*(self->ptime * self->rate)/1000*/self->ptime;
|
||||
jb_put(self->jb.jbuffer, *data, JB_TYPE_VOICE, self->ptime, ts, (long)tsk_time_now(), self->jb.jcodec);
|
||||
jb_put(self->jb.jbuffer, *data, JB_TYPE_VOICE, self->ptime, rtp_hdr->timestamp, (long)tsk_time_now(), self->jb.jcodec);
|
||||
*data = tsk_null;
|
||||
tsk_safeobj_unlock(self);
|
||||
|
||||
|
|
|
@ -29,3 +29,67 @@
|
|||
*/
|
||||
#include "tinydav/audio/tdav_producer_audio.h"
|
||||
|
||||
#define TDAV_BITS_PER_SAMPLE_DEFAULT 16
|
||||
#define TDAV_CHANNELS_DEFAULT 2
|
||||
#define TDAV_RATE_DEFAULT 8000
|
||||
#define TDAV_PTIME_DEFAULT 20
|
||||
|
||||
#include "tsk_debug.h"
|
||||
|
||||
/** Initialize Audio producer
|
||||
* @param self The producer to initialize
|
||||
*/
|
||||
int tdav_producer_audio_init(tdav_producer_audio_t* self)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
/* base */
|
||||
if((ret = tmedia_producer_init(TMEDIA_PRODUCER(self)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* self (should be update by prepare() by using the codec's info)*/
|
||||
self->bits_per_sample = TDAV_BITS_PER_SAMPLE_DEFAULT;
|
||||
self->channels = TDAV_CHANNELS_DEFAULT;
|
||||
self->rate = TDAV_RATE_DEFAULT;
|
||||
self->ptime = TDAV_PTIME_DEFAULT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic function to compare two producers.
|
||||
* @param producer1 The first producer to compare.
|
||||
* @param producer2 The second producer to compare.
|
||||
* @retval Returns an integral value indicating the relationship between the two producers:
|
||||
* <0 : @a producer1 less than @a producer2.<br>
|
||||
* 0 : @a producer1 identical to @a producer2.<br>
|
||||
* >0 : @a producer1 greater than @a producer2.<br>
|
||||
*/
|
||||
int tdav_producer_audio_cmp(const tsk_object_t* producer1, const tsk_object_t* producer2)
|
||||
{
|
||||
return (TDAV_PRODUCER_AUDIO(producer1) - TDAV_PRODUCER_AUDIO(producer2));
|
||||
}
|
||||
|
||||
/** Deinitialize a producer
|
||||
*/
|
||||
int tdav_producer_audio_deinit(self)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* base */
|
||||
if((ret = tmedia_producer_deinit(TMEDIA_PRODUCER(self)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -30,6 +30,7 @@
|
|||
#include "tinydav/audio/tdav_session_audio.h"
|
||||
|
||||
#include "tinymedia/tmedia_consumer.h"
|
||||
#include "tinymedia/tmedia_producer.h"
|
||||
|
||||
#include "tinyrtp/trtp_manager.h"
|
||||
#include "tinyrtp/rtp/trtp_rtp_packet.h"
|
||||
|
@ -39,7 +40,7 @@
|
|||
|
||||
extern const tmedia_codec_t* _tmedia_session_match_codec(tmedia_session_t* self, const tsdp_header_M_t* M, char** format);
|
||||
|
||||
|
||||
// RTP/RTCP callback
|
||||
static int tdav_session_audio_rtp_cb(const void* callback_data, const struct trtp_rtp_packet_s* packet)
|
||||
{
|
||||
tdav_session_audio_t* audio = (tdav_session_audio_t*)callback_data;
|
||||
|
@ -56,7 +57,7 @@ static int tdav_session_audio_rtp_cb(const void* callback_data, const struct trt
|
|||
tsk_size_t out_size;
|
||||
out_size = TMEDIA_SESSION(audio)->negociated_codec->plugin->decode(TMEDIA_SESSION(audio)->negociated_codec, packet->payload.data, packet->payload.size, &out_data);
|
||||
if(out_size){
|
||||
tmedia_consumer_consume(audio->consumer, &out_data, out_size);
|
||||
tmedia_consumer_consume(audio->consumer, &out_data, out_size, packet->header);
|
||||
}
|
||||
TSK_FREE(out_data);
|
||||
}
|
||||
|
@ -64,6 +65,17 @@ static int tdav_session_audio_rtp_cb(const void* callback_data, const struct trt
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Producer callback
|
||||
static int tdav_session_audio_producer_cb(const void* callback_data, const void* buffer, tsk_size_t size)
|
||||
{
|
||||
tdav_session_audio_t* audio = (tdav_session_audio_t*)callback_data;
|
||||
|
||||
if(audio){
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ============ Plugin interface ================= */
|
||||
|
||||
|
@ -168,6 +180,11 @@ int tdav_session_audio_start(tmedia_session_t* self)
|
|||
tmedia_consumer_prepare(audio->consumer, self->negociated_codec);
|
||||
tmedia_consumer_start(audio->consumer);
|
||||
}
|
||||
/* Producer */
|
||||
if(audio->producer){
|
||||
tmedia_producer_prepare(audio->producer, self->negociated_codec);
|
||||
tmedia_producer_start(audio->producer);
|
||||
}
|
||||
|
||||
/* for test */
|
||||
//trtp_manager_send_rtp(audio->rtp_manager, "test", 4, tsk_true);
|
||||
|
@ -203,6 +220,10 @@ int tdav_session_audio_stop(tmedia_session_t* self)
|
|||
if(audio->consumer){
|
||||
tmedia_consumer_stop(audio->consumer);
|
||||
}
|
||||
/* Producer */
|
||||
if(audio->producer){
|
||||
tmedia_producer_stop(audio->producer);
|
||||
}
|
||||
|
||||
/* very important */
|
||||
//audio->local_port = 0;
|
||||
|
@ -227,6 +248,10 @@ int tdav_session_audio_pause(tmedia_session_t* self)
|
|||
if(audio->consumer){
|
||||
tmedia_consumer_pause(audio->consumer);
|
||||
}
|
||||
/* Producer */
|
||||
if(audio->producer){
|
||||
tmedia_producer_pause(audio->producer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -328,6 +353,12 @@ static tsk_object_t* tdav_session_audio_ctor(tsk_object_t * self, va_list * app)
|
|||
if(!(session->consumer = tmedia_consumer_create(tdav_session_audio_plugin_def_t->type))){
|
||||
TSK_DEBUG_ERROR("Failed to create Audio consumer");
|
||||
}
|
||||
if((session->producer = tmedia_producer_create(tdav_session_audio_plugin_def_t->type))){
|
||||
tmedia_producer_set_callback(session->producer, tdav_session_audio_producer_cb, self);
|
||||
}
|
||||
else{
|
||||
TSK_DEBUG_ERROR("Failed to create Audio producer");
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -341,6 +372,7 @@ static tsk_object_t* tdav_session_audio_dtor(tsk_object_t * self)
|
|||
/* deinit self */
|
||||
TSK_OBJECT_SAFE_FREE(session->rtp_manager);
|
||||
TSK_OBJECT_SAFE_FREE(session->consumer);
|
||||
TSK_OBJECT_SAFE_FREE(session->producer);
|
||||
TSK_FREE(session->remote_ip);
|
||||
TSK_FREE(session->local_ip);
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ int tdav_consumer_waveapi_start(tmedia_consumer_t* self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdav_consumer_waveapi_consume(tmedia_consumer_t* self, void** buffer, tsk_size_t size)
|
||||
int tdav_consumer_waveapi_consume(tmedia_consumer_t* self, void** buffer, tsk_size_t size, const tsk_object_t* proto_hdr)
|
||||
{
|
||||
tdav_consumer_waveapi_t* consumer = (tdav_consumer_waveapi_t*)self;
|
||||
|
||||
|
@ -282,7 +282,7 @@ int tdav_consumer_waveapi_consume(tmedia_consumer_t* self, void** buffer, tsk_si
|
|||
return -1;
|
||||
}
|
||||
/* buffer is already decoded */
|
||||
return tdav_consumer_audio_put(TDAV_CONSUMER_AUDIO(consumer), buffer);
|
||||
return tdav_consumer_audio_put(TDAV_CONSUMER_AUDIO(consumer), buffer, proto_hdr);
|
||||
}
|
||||
|
||||
int tdav_consumer_waveapi_pause(tmedia_consumer_t* self)
|
||||
|
|
|
@ -0,0 +1,390 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Mamadou Diop.
|
||||
*
|
||||
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
|
||||
*
|
||||
* This file is part of Open Source Doubango Framework.
|
||||
*
|
||||
* DOUBANGO is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DOUBANGO is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with DOUBANGO.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file tdav_producer_waveapi.c
|
||||
* @brief Audio Consumer for Win32 and WinCE platforms.
|
||||
*
|
||||
* @author Mamadou Diop <diopmamadou(at)doubango.org>
|
||||
*
|
||||
* @date Created: Sat Nov 8 16:54:58 2009 mdiop
|
||||
*/
|
||||
#include "tinydav/audio/waveapi/tdav_producer_waveapi.h"
|
||||
|
||||
#if HAVE_WAVE_API
|
||||
|
||||
#include "tsk_thread.h"
|
||||
#include "tsk_memory.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#define TDAV_WAVEAPI_PRODUCER_ERROR_BUFF_COUNT 0xFF
|
||||
|
||||
static void print_last_error(MMRESULT mmrError, const char* func)
|
||||
{
|
||||
static char buffer_err[TDAV_WAVEAPI_PRODUCER_ERROR_BUFF_COUNT];
|
||||
|
||||
waveInGetErrorTextA(mmrError, buffer_err, sizeof(buffer_err));
|
||||
TSK_DEBUG_ERROR("%s() error: %s", func, buffer_err);
|
||||
}
|
||||
|
||||
static int free_wavehdr(tdav_producer_waveapi_t* producer, tsk_size_t index)
|
||||
{
|
||||
if(!producer || index >= sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR)){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
TSK_FREE(producer->hWaveHeaders[index]->lpData);
|
||||
TSK_FREE(producer->hWaveHeaders[index]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int create_wavehdr(tdav_producer_waveapi_t* producer, tsk_size_t index)
|
||||
{
|
||||
if(!producer || index >= sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR)){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(producer->hWaveHeaders[index]){
|
||||
free_wavehdr(producer, index);
|
||||
}
|
||||
|
||||
producer->hWaveHeaders[index] = tsk_calloc(1, sizeof(WAVEHDR));
|
||||
producer->hWaveHeaders[index]->lpData = tsk_calloc(1, producer->bytes_per_notif);
|
||||
producer->hWaveHeaders[index]->dwBufferLength = producer->bytes_per_notif;
|
||||
producer->hWaveHeaders[index]->dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP;
|
||||
producer->hWaveHeaders[index]->dwLoops = 0x01;
|
||||
producer->hWaveHeaders[index]->dwUser = index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_wavehdr(tdav_producer_waveapi_t* producer, tsk_size_t index)
|
||||
{
|
||||
MMRESULT result;
|
||||
|
||||
if(!producer || !producer->hWaveHeaders[index] || !producer->hWaveIn){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = waveInPrepareHeader(producer->hWaveIn, producer->hWaveHeaders[index], sizeof(WAVEHDR));
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInPrepareHeader");
|
||||
return -2;
|
||||
}
|
||||
|
||||
result = waveInAddBuffer(producer->hWaveIn, producer->hWaveHeaders[index], sizeof(WAVEHDR));
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInWrite");
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int record_wavehdr(tdav_producer_waveapi_t* producer, LPWAVEHDR lpHdr)
|
||||
{
|
||||
MMRESULT result;
|
||||
|
||||
if(!producer || !lpHdr || !producer->hWaveIn){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Alert the session that there is new data to send over the network
|
||||
//
|
||||
if(TMEDIA_PRODUCER(producer)->callback){
|
||||
TMEDIA_PRODUCER(producer)->callback(TMEDIA_PRODUCER(producer)->callback_data, lpHdr->lpData, (lpHdr->dwBytesRecorded/2));
|
||||
}
|
||||
|
||||
|
||||
if(!producer->started){
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = waveInUnprepareHeader(producer->hWaveIn, lpHdr, sizeof(WAVEHDR));
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInUnprepareHeader");
|
||||
return -2;
|
||||
}
|
||||
|
||||
result = waveInPrepareHeader(producer->hWaveIn, lpHdr, sizeof(WAVEHDR));
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInPrepareHeader");
|
||||
return -3;
|
||||
}
|
||||
|
||||
result = waveInAddBuffer(producer->hWaveIn, lpHdr, sizeof(WAVEHDR));
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInWrite");
|
||||
return -4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *__record_thread(void *param)
|
||||
{
|
||||
tdav_producer_waveapi_t* producer = (tdav_producer_waveapi_t*)param;
|
||||
DWORD dwEvent;
|
||||
tsk_size_t i;
|
||||
|
||||
TSK_DEBUG_INFO("__record_thread -- START");
|
||||
|
||||
SetPriorityClass(GetCurrentThread(), REALTIME_PRIORITY_CLASS);
|
||||
|
||||
for(;;){
|
||||
dwEvent = WaitForMultipleObjects(2, producer->events, FALSE, INFINITE);
|
||||
|
||||
if (dwEvent == 1){
|
||||
break;
|
||||
}
|
||||
|
||||
else if (dwEvent == 0){
|
||||
EnterCriticalSection(&producer->cs);
|
||||
for(i = 0; i< sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR); i++){
|
||||
if(producer->hWaveHeaders[i] && (producer->hWaveHeaders[i]->dwFlags & WHDR_DONE)){
|
||||
record_wavehdr(producer, producer->hWaveHeaders[i]);
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&producer->cs);
|
||||
}
|
||||
}
|
||||
|
||||
TSK_DEBUG_INFO("__record_thread() -- STOP");
|
||||
|
||||
|
||||
return tsk_null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ============ Media Producer Interface ================= */
|
||||
int tdav_producer_waveapi_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec)
|
||||
{
|
||||
tdav_producer_waveapi_t* producer = (tdav_producer_waveapi_t*)self;
|
||||
tsk_size_t i;
|
||||
|
||||
if(!producer || !codec && codec->plugin){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
TDAV_PRODUCER_AUDIO(producer)->channels = codec->plugin->audio.channels;
|
||||
TDAV_PRODUCER_AUDIO(producer)->rate = codec->plugin->rate;
|
||||
/* codec should have ptime */
|
||||
|
||||
|
||||
/* Format */
|
||||
ZeroMemory(&producer->wfx, sizeof(WAVEFORMATEX));
|
||||
producer->wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
producer->wfx.nChannels = TDAV_PRODUCER_AUDIO(producer)->channels;
|
||||
producer->wfx.nSamplesPerSec = TDAV_PRODUCER_AUDIO(producer)->rate;
|
||||
producer->wfx.wBitsPerSample = TDAV_PRODUCER_AUDIO(producer)->bits_per_sample;
|
||||
producer->wfx.nBlockAlign = (producer->wfx.nChannels * producer->wfx.wBitsPerSample/8);
|
||||
producer->wfx.nAvgBytesPerSec = (producer->wfx.nSamplesPerSec * producer->wfx.nBlockAlign);
|
||||
|
||||
/* Average bytes (count) for each notification */
|
||||
producer->bytes_per_notif = ((producer->wfx.nAvgBytesPerSec * TDAV_PRODUCER_AUDIO(producer)->ptime)/1000);
|
||||
|
||||
/* create buffers */
|
||||
for(i = 0; i< sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR); i++){
|
||||
create_wavehdr(producer, i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdav_producer_waveapi_start(tmedia_producer_t* self)
|
||||
{
|
||||
tdav_producer_waveapi_t* producer = (tdav_producer_waveapi_t*)self;
|
||||
MMRESULT result;
|
||||
tsk_size_t i;
|
||||
|
||||
if(!producer){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(producer->started || producer->hWaveIn){
|
||||
TSK_DEBUG_WARN("Consumer already started");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* create events */
|
||||
if(!producer->events[0]){
|
||||
producer->events[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
}
|
||||
if(!producer->events[1]){
|
||||
producer->events[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
}
|
||||
|
||||
/* open */
|
||||
result = waveInOpen((HWAVEIN *)&producer->hWaveIn, /*WAVE_MAPPER*/0, &producer->wfx, (DWORD)producer->events[0], (DWORD_PTR)producer, CALLBACK_EVENT);
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInOpen");
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* start */
|
||||
result = waveInStart(producer->hWaveIn);
|
||||
if(result != MMSYSERR_NOERROR){
|
||||
print_last_error(result, "waveInStart");
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* start thread */
|
||||
tsk_thread_create(&producer->tid[0], __record_thread, producer);
|
||||
|
||||
/* write */
|
||||
for(i = 0; i< sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR); i++){
|
||||
add_wavehdr(producer, i);
|
||||
}
|
||||
|
||||
producer->started = tsk_true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdav_producer_waveapi_pause(tmedia_producer_t* self)
|
||||
{
|
||||
tdav_producer_waveapi_t* producer = (tdav_producer_waveapi_t*)self;
|
||||
|
||||
if(!producer){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdav_producer_waveapi_stop(tmedia_producer_t* self)
|
||||
{
|
||||
tdav_producer_waveapi_t* producer = (tdav_producer_waveapi_t*)self;
|
||||
MMRESULT result;
|
||||
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!producer->started){
|
||||
TSK_DEBUG_WARN("Consumer not started");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* stop thread */
|
||||
if(producer->tid[0]){
|
||||
SetEvent(producer->events[1]);
|
||||
tsk_thread_join(&(producer->tid[0]));
|
||||
}
|
||||
|
||||
/* should be done here */
|
||||
producer->started = tsk_false;
|
||||
|
||||
if(producer->hWaveIn && (((result = waveInReset(producer->hWaveIn)) != MMSYSERR_NOERROR) || ((result = waveInClose(producer->hWaveIn)) != MMSYSERR_NOERROR))){
|
||||
print_last_error(result, "waveInReset/waveInClose");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// WaveAPI producer object definition
|
||||
//
|
||||
/* constructor */
|
||||
static tsk_object_t* tdav_producer_waveapi_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tdav_producer_waveapi_t *producer = self;
|
||||
if(producer){
|
||||
/* init base */
|
||||
tdav_producer_audio_init(TDAV_PRODUCER_AUDIO(producer));
|
||||
/* init self */
|
||||
InitializeCriticalSection(&producer->cs);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
/* destructor */
|
||||
static tsk_object_t* tdav_producer_waveapi_dtor(tsk_object_t * self)
|
||||
{
|
||||
tdav_producer_waveapi_t *producer = self;
|
||||
if(producer){
|
||||
tsk_size_t i;
|
||||
|
||||
/* stop */
|
||||
if(producer->started){
|
||||
tdav_producer_waveapi_stop(self);
|
||||
}
|
||||
|
||||
/* deinit base */
|
||||
tdav_producer_audio_deinit(TDAV_PRODUCER_AUDIO(producer));
|
||||
/* deinit self */
|
||||
for(i = 0; i< sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR); i++){
|
||||
free_wavehdr(producer, i);
|
||||
}
|
||||
if(producer->hWaveIn){
|
||||
waveInClose(producer->hWaveIn);
|
||||
}
|
||||
if(producer->events[0]){
|
||||
CloseHandle(producer->events[0]);
|
||||
}
|
||||
if(producer->events[1]){
|
||||
CloseHandle(producer->events[1]);
|
||||
}
|
||||
DeleteCriticalSection(&producer->cs);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
/* object definition */
|
||||
static const tsk_object_def_t tdav_producer_waveapi_def_s =
|
||||
{
|
||||
sizeof(tdav_producer_waveapi_t),
|
||||
tdav_producer_waveapi_ctor,
|
||||
tdav_producer_waveapi_dtor,
|
||||
tdav_producer_audio_cmp,
|
||||
};
|
||||
/* plugin definition*/
|
||||
static const tmedia_producer_plugin_def_t tmedia_producer_waveapi_plugin_def_s =
|
||||
{
|
||||
&tdav_producer_waveapi_def_s,
|
||||
|
||||
tmedia_audio,
|
||||
"Microsoft WaveAPI producer",
|
||||
|
||||
tdav_producer_waveapi_prepare,
|
||||
tdav_producer_waveapi_start,
|
||||
tdav_producer_waveapi_pause,
|
||||
tdav_producer_waveapi_stop
|
||||
};
|
||||
const tmedia_producer_plugin_def_t *tmedia_producer_waveapi_plugin_def_t = &tmedia_producer_waveapi_plugin_def_s;
|
||||
|
||||
#endif /* HAVE_WAVE_API */
|
|
@ -40,6 +40,7 @@
|
|||
#include "tinydav/audio/directsound/tdav_consumer_dsound.h"
|
||||
|
||||
// Producers
|
||||
#include "tinydav/audio/waveapi/tdav_producer_waveapi.h"
|
||||
|
||||
#if 0
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
@ -79,6 +80,12 @@ int tdav_init()
|
|||
tmedia_consumer_plugin_register(tmedia_consumer_oss_plugin_def_t);
|
||||
#endif
|
||||
|
||||
/* === Register producers === */
|
||||
#if HAVE_DSOUND_H
|
||||
#elif HAVE_WAVE_API
|
||||
tmedia_producer_plugin_register(tmedia_producer_waveapi_plugin_def_t);
|
||||
#endif
|
||||
|
||||
//if((context_encode = avcodec_alloc_context())){
|
||||
// printf("avcodec_alloc_context()");
|
||||
//}
|
||||
|
@ -111,6 +118,12 @@ int tdav_deinit()
|
|||
tmedia_consumer_plugin_unregister(tmedia_consumer_waveapi_plugin_def_t);
|
||||
#endif
|
||||
|
||||
/* === UnRegister producers === */
|
||||
#if HAVE_DSOUND_H
|
||||
#elif HAVE_WAVE_API
|
||||
tmedia_producer_plugin_unregister(tmedia_producer_waveapi_plugin_def_t);
|
||||
#endif
|
||||
|
||||
#if HAVE_OSS_H
|
||||
tmedia_consumer_plugin_unregister(tmedia_consumer_oss_plugin_def_t);
|
||||
#endif
|
||||
|
|
|
@ -73,7 +73,7 @@ void test_sessions_client()
|
|||
tmedia_type_t type = tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38;
|
||||
|
||||
mgr = tmedia_session_mgr_create(type,
|
||||
"192.168.0.12", tsk_false, tsk_true/* offerer */);
|
||||
"0.0.0.0", tsk_false, tsk_true/* offerer */);
|
||||
|
||||
/* get lo */
|
||||
sdp_lo = tmedia_session_mgr_get_lo(mgr);
|
||||
|
@ -113,7 +113,7 @@ void test_sessions_server()
|
|||
if((sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))){
|
||||
type = tmedia_type_from_sdp(sdp_ro);
|
||||
mgr = tmedia_session_mgr_create(type,
|
||||
"192.168.0.12", tsk_false, tsk_false/* answerer */);
|
||||
"0.0.0.0", tsk_false, tsk_false/* answerer */);
|
||||
tmedia_session_mgr_set_ro(mgr, sdp_ro);
|
||||
TSK_OBJECT_SAFE_FREE(sdp_ro);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#++sn --path ./core-colibria.sn
|
||||
|
||||
# Ericsson
|
||||
++sn --path ./core-ericsson.sn
|
||||
#++sn --path ./core-ericsson.sn
|
||||
|
||||
# Inexbee
|
||||
#++sn --path ./core-inexbee.sn
|
||||
|
@ -21,4 +21,4 @@
|
|||
|
||||
|
||||
# SigComp
|
||||
#++sn --path ./sigcomp.sn
|
||||
++sn --path ./sigcomp.sn
|
|
@ -4,12 +4,12 @@
|
|||
# However, for performance reasons, in your application you should use only one Compartment for all sessions.
|
||||
|
||||
# user's parameters (like ANSI-C #define)
|
||||
%%domain ericsson.com
|
||||
%%user mamadou
|
||||
%%pwd mamadou
|
||||
%%proxy_ip 192.168.0.13 # IP address or FQDN
|
||||
%%proxy_port 5081
|
||||
%%proxy_trans tcp # udp, tcp, tls or sctp
|
||||
%%domain sigcomp.org
|
||||
%%user bob
|
||||
%%pwd bob
|
||||
%%proxy_ip 192.168.16.227 # IP address or FQDN
|
||||
%%proxy_port 4060
|
||||
%%proxy_trans udp # udp, tcp, tls or sctp
|
||||
%%expires 100 # expires used by all dialogs
|
||||
%%sleep-sec 1.0 # number of seconds to wait before sending next sip message
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
|||
|
||||
# Configure the stack
|
||||
# Realm, IMPI and IMPU are mandatory
|
||||
++cst --realm $$(domain) --impi $$(user)@$$(domain) --impu sip:$$(user)@$$(domain) --pwd $$(pwd) \
|
||||
--pcscf-ip $$(proxy_ip) --pcscf-port $$(proxy_port) --pcscf-trans $$(proxy_trans) \
|
||||
++cst --realm $$(domain) --impi $$(user) --impu sip:$$(user)@$$(domain) --pwd $$(pwd) \
|
||||
--pcscf-ip $$(proxy_ip) --pcscf-port $$(proxy_port) --pcscf-trans $$(proxy_trans) --local-port 5060 \
|
||||
--sigcomp-id urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a473 \
|
||||
--sigcomp-id urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a474 \
|
||||
--header Privacy=none --header Allow=INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER \
|
||||
|
@ -44,9 +44,9 @@
|
|||
++sleep --sec 1
|
||||
|
||||
# SUBSCRIBE to reg event package (silent hangup)
|
||||
++sub --to sip:$$(user)@$$(domain) --xp $$(expires) --silent --header Event=reg --header Accept=application/reginfo+xml \
|
||||
--sigcomp-id urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a474 \
|
||||
--header Allow-Events=refer, presence, presence.winfo, xcap-diff, conference >>(sub-reg-sid)
|
||||
#++sub --to sip:$$(user)@$$(domain) --xp $$(expires) --silent --header Event=reg --header Accept=application/reginfo+xml \
|
||||
# --sigcomp-id urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a474 \
|
||||
# --header Allow-Events=refer, presence, presence.winfo, xcap-diff, conference >>(sub-reg-sid)
|
||||
|
||||
# Press ENTER
|
||||
++sleep --sec -1
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef struct tmedia_consumer_plugin_def_s
|
|||
|
||||
int (* prepare) (tmedia_consumer_t*, const tmedia_codec_t* );
|
||||
int (* start) (tmedia_consumer_t* );
|
||||
int (* consume) (tmedia_consumer_t*, void** buffer, tsk_size_t size);
|
||||
int (* consume) (tmedia_consumer_t*, void** buffer, tsk_size_t size, const tsk_object_t* proto_hdr);
|
||||
int (* pause) (tmedia_consumer_t* );
|
||||
int (* stop) (tmedia_consumer_t* );
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ TINYMEDIA_API tmedia_consumer_t* tmedia_consumer_create(tmedia_type_t type);
|
|||
TINYMEDIA_API int tmedia_consumer_init(tmedia_consumer_t* self);
|
||||
TINYMEDIA_API int tmedia_consumer_prepare(tmedia_consumer_t *self, const tmedia_codec_t* codec);
|
||||
TINYMEDIA_API int tmedia_consumer_start(tmedia_consumer_t *self);
|
||||
TINYMEDIA_API int tmedia_consumer_consume(tmedia_consumer_t* self, void** buffer, tsk_size_t size);
|
||||
TINYMEDIA_API int tmedia_consumer_consume(tmedia_consumer_t* self, void** buffer, tsk_size_t size, const tsk_object_t* proto_hdr);
|
||||
TINYMEDIA_API int tmedia_consumer_pause(tmedia_consumer_t *self);
|
||||
TINYMEDIA_API int tmedia_consumer_stop(tmedia_consumer_t *self);
|
||||
TINYMEDIA_API int tmedia_consumer_deinit(tmedia_consumer_t* self);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "tinymedia_config.h"
|
||||
|
||||
#include "tinymedia/tmedia_codec.h"
|
||||
#include "tmedia_common.h"
|
||||
|
||||
/**Max number of plugins (producer types) we can create */
|
||||
|
@ -69,7 +70,7 @@ typedef struct tmedia_producer_plugin_def_s
|
|||
//! full description (usefull for debugging)
|
||||
const char* desc;
|
||||
|
||||
int (* prepare) (tmedia_producer_t* );
|
||||
int (* prepare) (tmedia_producer_t* , const tmedia_codec_t*);
|
||||
int (* start) (tmedia_producer_t* );
|
||||
int (* pause) (tmedia_producer_t* );
|
||||
int (* stop) (tmedia_producer_t* );
|
||||
|
@ -81,11 +82,13 @@ tmedia_producer_plugin_def_t;
|
|||
TINYMEDIA_API tmedia_producer_t* tmedia_producer_create(tmedia_type_t type);
|
||||
TINYMEDIA_API int tmedia_producer_init(tmedia_producer_t* self);
|
||||
TINYMEDIA_API int tmedia_producer_set_callback(tmedia_producer_t *self, tmedia_producer_cb_f callback, const void* callback_data);
|
||||
TINYMEDIA_API int tmedia_producer_prepare(tmedia_producer_t *self);
|
||||
TINYMEDIA_API int tmedia_producer_prepare(tmedia_producer_t *self, const tmedia_codec_t* codec);
|
||||
TINYMEDIA_API int tmedia_producer_start(tmedia_producer_t *self);
|
||||
TINYMEDIA_API int tmedia_producer_pause(tmedia_producer_t *self);
|
||||
TINYMEDIA_API int tmedia_producer_stop(tmedia_producer_t *self);
|
||||
|
||||
TINYMEDIA_API int tmedia_producer_deinit(tmedia_producer_t* self);
|
||||
|
||||
TINYMEDIA_API int tmedia_producer_plugin_register(const tmedia_producer_plugin_def_t* plugin);
|
||||
TINYMEDIA_API int tmedia_producer_plugin_unregister(const tmedia_producer_plugin_def_t* plugin);
|
||||
|
||||
#endif /* TINYMEDIA_PRODUCER_H */
|
||||
|
|
|
@ -45,8 +45,6 @@ TMEDIA_BEGIN_DECLS
|
|||
/**Max number of plugins (session types) we can create */
|
||||
#define TMED_SESSION_MAX_PLUGINS 0x0F
|
||||
|
||||
#define TMEDIA_SESSION_SET();
|
||||
|
||||
/** Base objct used for all media sessions */
|
||||
typedef struct tmedia_session_s
|
||||
{
|
||||
|
@ -114,18 +112,6 @@ typedef tsk_list_t tmedia_sessions_L_t; /**< List of @ref tmedia_session_t objec
|
|||
typedef struct tmedia_session_audio_s
|
||||
{
|
||||
TMEDIA_DECLARE_SESSION;
|
||||
|
||||
/** Will be passed to the rtp session which will call this function to signal that
|
||||
* there is new data (from the network). It's up to the session to decode the data using
|
||||
* the negociated codec. Once the data is decoded, it should be passed to the consumer.
|
||||
*/
|
||||
int (* from_rtp_cb) (struct tmedia_session_audio_s* self, const void* data, tsk_size_t size);
|
||||
/**! Will be passed to the producer which will call this callback to signal
|
||||
* that there is new data to send. @a data contains raw audio buffer (most likely PCM 16bit).
|
||||
* The data should be encoded using the negociated codec
|
||||
* before to be sent over the network (using the rtp session).
|
||||
*/
|
||||
int (* from_producer_cb) (struct tmedia_session_audio_s* self, const void* data, tsk_size_t size);
|
||||
}
|
||||
tmedia_session_audio_t;
|
||||
#define tmedia_session_audio_init(self) tmedia_session_init(TMEDIA_SESSION(self), tmed_sess_type_audio)
|
||||
|
@ -137,18 +123,6 @@ tmedia_session_audio_t;
|
|||
typedef struct tmedia_session_video_s
|
||||
{
|
||||
TMEDIA_DECLARE_SESSION;
|
||||
|
||||
/** Will be passed to the rtp session which will call this function to signal that
|
||||
* there is new data (from the network). It's up to the session to decode the data using
|
||||
* the negociated codec. Once the data is decoded, it should be passed to the consumer.
|
||||
*/
|
||||
int (* from_rtp_cb) (struct tmedia_session_video_s* self, const void* data, tsk_size_t size);
|
||||
/**! Will be passed to the producer which will call this callback to signal
|
||||
* that there is new data to send. @a data contains raw audio buffer (most likely PCM 16bit).
|
||||
* The data should be encoded using the negociated codec
|
||||
* before to be sent over the network (using the rtp session).
|
||||
*/
|
||||
int (* from_producer_cb) (struct tmedia_session_video_s* self, const void* data, tsk_size_t size);
|
||||
}
|
||||
tmedia_session_video_t;
|
||||
#define tmedia_session_video_init(self) tmedia_session_init(TMEDIA_SESSION(self), tmed_sess_type_video)
|
||||
|
|
|
@ -88,13 +88,13 @@ int tmedia_consumer_start(tmedia_consumer_t *self)
|
|||
* @param buffer Pointer to the data to consume
|
||||
* @param size Size of the data to consume
|
||||
*/
|
||||
int tmedia_consumer_consume(tmedia_consumer_t* self, void** buffer, tsk_size_t size)
|
||||
int tmedia_consumer_consume(tmedia_consumer_t* self, void** buffer, tsk_size_t size, const tsk_object_t* proto_hdr)
|
||||
{
|
||||
if(!self || !self->plugin || !self->plugin->consume){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
return self->plugin->consume(self, buffer, size);
|
||||
return self->plugin->consume(self, buffer, size, proto_hdr);
|
||||
}
|
||||
|
||||
/**@ingroup tmedia_consumer_group
|
||||
|
|
|
@ -77,15 +77,16 @@ int tmedia_producer_set_callback(tmedia_producer_t *self, tmedia_producer_cb_f c
|
|||
/**@ingroup tmedia_producer_group
|
||||
* Alert the producer to be prepared to start.
|
||||
* @param self the producer to prepare
|
||||
* @param codec The codec to use to prepare the producer
|
||||
* @retval Zero if succeed and non-zero error code otherwise
|
||||
*/
|
||||
int tmedia_producer_prepare(tmedia_producer_t *self)
|
||||
int tmedia_producer_prepare(tmedia_producer_t *self, const tmedia_codec_t* codec)
|
||||
{
|
||||
if(!self || !self->plugin || !self->plugin->prepare){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
return self->plugin->prepare(self);
|
||||
return self->plugin->prepare(self, codec);
|
||||
}
|
||||
|
||||
/**@ingroup tmedia_producer_group
|
||||
|
|
|
@ -120,13 +120,10 @@ int trtp_manager_prepare(trtp_manager_t* self)
|
|||
|
||||
/* Creates local rtp and rtcp sockets */
|
||||
while(retry_count--){
|
||||
tnet_port_t local_port = TNET_SOCKET_PORT_ANY;
|
||||
|
||||
/* random number in the range 1024 to 65535 */
|
||||
if(self->enable_rtcp){
|
||||
local_port = ((rand() % 64511) + 1024);
|
||||
local_port = (local_port % 0x01) ? (local_port + 1) : local_port; /* turn to even number */
|
||||
}
|
||||
tnet_port_t local_port = ((rand() % 64510) + 1025);
|
||||
local_port = (local_port & 0xFFFE); /* turn to even number */
|
||||
|
||||
/* beacuse failure will cause errors in the log, print a message to alert that there is
|
||||
* nothing to worry about */
|
||||
TSK_DEBUG_INFO("RTP/RTCP manager[Begin]: Trying to bind to random ports");
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
TSIP_BEGIN_DECLS
|
||||
|
||||
#define TSIP_IS_SIGCOMP_DATA(data) ((data) && (*((uint8_t*)data) & 0xF8) == 0xF8)
|
||||
|
||||
#define TSIP_SIGCOMP_DMS 8192
|
||||
#define TSIP_SIGCOMP_SMS 8192
|
||||
#define TSIP_SIGCOMP_CPB 64
|
||||
|
@ -49,6 +51,7 @@ tsip_sigcomp_handle_t* tsip_sigcomp_handler_create(uint8_t cpb, uint32_t dms, ui
|
|||
int tsip_sigcomp_handler_set_dicts(tsip_sigcomp_handle_t* self, tsk_bool_t sip_n_sdp, tsk_bool_t pres);
|
||||
int tsip_sigcomp_handler_add_compartment(tsip_sigcomp_handle_t* self, const char* comp_id);
|
||||
int tsip_sigcomp_handler_remove_compartment(tsip_sigcomp_handle_t* self, const char* comp_id);
|
||||
int tsip_sigcomp_close_all(tsip_sigcomp_handle_t* self);
|
||||
tsk_size_t tsip_sigcomp_handler_compress(tsip_sigcomp_handle_t* self, const char* comp_id, tsk_bool_t is_stream, const void* in_data, tsk_size_t in_size, void* out_data, tsk_size_t out_maxsize);
|
||||
tsk_size_t tsip_sigcomp_handler_uncompress(tsip_sigcomp_handle_t* self, const char* comp_id, tsk_bool_t is_stream, const void* in_data, tsk_size_t in_size, void* out_data, tsk_size_t out_maxsize, tsk_bool_t* is_nack);
|
||||
tsk_size_t tsip_sigcomp_handler_uncompress_next(tsip_sigcomp_handle_t* self, const char* comp_id, void** nack_data, tsk_bool_t* is_nack);
|
||||
|
|
|
@ -185,7 +185,7 @@ tsip_stack_param_type_t;
|
|||
*/
|
||||
/**@ingroup tsip_stack_group
|
||||
* @def TSIP_STACK_SET_SIGCOMP_NEW_COMPARTMENT
|
||||
* Add New unique compartment identifier to the stack. This compartment will be removed when the stack is stopped.
|
||||
* Add New unique compartment identifier to the stack. This compartment will be closed (not removed) when the stack is stopped.
|
||||
* A any time, you can remove this compartment by using @ref TSIP_STACK_UNSET_SIGCOMP_COMPARTMENT().
|
||||
* @param COMPARTMENT_ID_STR The id of the compartment to add. Should be unique.
|
||||
* The identifier will be used to in the sip headers (as per RFC 5049) "AS IS".<br>
|
||||
|
|
|
@ -305,7 +305,7 @@ tsip_header_t *tsip_challenge_create_header_authorization(tsip_challenge_t *self
|
|||
goto bail;
|
||||
}
|
||||
|
||||
if(!(uristring = tsip_uri_tostring(request->line.request.uri, tsk_true, tsk_true))){
|
||||
if(!(uristring = tsip_uri_tostring(request->line.request.uri, tsk_true, tsk_false))){
|
||||
TSK_DEBUG_ERROR("Failed to parse URI: %s", uristring);
|
||||
goto bail;
|
||||
}
|
||||
|
|
|
@ -685,7 +685,7 @@ int tsip_dialog_update_challenges(tsip_dialog_t *self, const tsip_response_t* re
|
|||
const tsip_header_WWW_Authenticate_t *WWW_Authenticate;
|
||||
const tsip_header_Proxy_Authenticate_t *Proxy_Authenticate;
|
||||
|
||||
/* RFC 2617 - Digest SSESSION
|
||||
/* RFC 2617 - HTTP Digest Session
|
||||
|
||||
* (A) The client response to a WWW-Authenticate challenge for a protection
|
||||
space starts an authentication session with that protection space.
|
||||
|
|
|
@ -217,6 +217,31 @@ int tsip_sigcomp_handler_remove_compartment(tsip_sigcomp_handle_t* self, const c
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Close all SigComp compartments
|
||||
* @param self The SigComp handler
|
||||
*/
|
||||
int tsip_sigcomp_close_all(tsip_sigcomp_handle_t* self)
|
||||
{
|
||||
tsip_sigcomp_t* sigcomp = self;
|
||||
const tsk_list_item_t* item;
|
||||
const char* comp_id;
|
||||
|
||||
if(!sigcomp){
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsk_safeobj_lock(sigcomp);
|
||||
|
||||
tsk_list_foreach(item, sigcomp->compartments){
|
||||
comp_id = ((tsip_sigcomp_compartment_t*)item->data)->id;
|
||||
tcomp_manager_closeCompartment(sigcomp->manager, comp_id, tsk_strlen(comp_id));
|
||||
}
|
||||
|
||||
tsk_safeobj_unlock(sigcomp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Compress a Sip message
|
||||
* @param self The SigComp handler
|
||||
* @param comp_id The id of the compartement to use for compression. This compartment should be previously added using
|
||||
|
@ -289,6 +314,8 @@ tsk_size_t tsip_sigcomp_handler_uncompress(tsip_sigcomp_handle_t* self, const ch
|
|||
return 0;
|
||||
}
|
||||
|
||||
*is_nack = tsk_false;
|
||||
|
||||
/* take ownership and lock() */
|
||||
compartment = tsk_object_ref(compartment); /* take ownership instead of locking the handler(which will lock all compartments) */
|
||||
tsk_safeobj_lock(compartment);
|
||||
|
|
|
@ -126,9 +126,7 @@ parse_buffer:
|
|||
* ==> Parse the SIP message without the content.
|
||||
*/
|
||||
tsk_ragel_state_init(&state, TSK_BUFFER_DATA(transport->buff_stream), endOfheaders + 4/*2CRLF*/);
|
||||
if(tsip_message_parse(&state, &message, tsk_false/* do not extract the content */) == tsk_true
|
||||
&& message->firstVia && message->Call_ID && message->CSeq && message->From && message->To)
|
||||
{
|
||||
if(tsip_message_parse(&state, &message, tsk_false/* do not extract the content */) == tsk_true){
|
||||
tsk_size_t clen = TSIP_MESSAGE_CONTENT_LENGTH(message); /* MUST have content-length header (see RFC 3261 - 7.5). If no CL header then the macro return zero. */
|
||||
if(clen == 0){ /* No content */
|
||||
tsk_buffer_remove(transport->buff_stream, 0, (endOfheaders + 4/*2CRLF*/)); /* Remove SIP headers and CRLF */
|
||||
|
@ -147,7 +145,7 @@ parse_buffer:
|
|||
}
|
||||
}
|
||||
|
||||
if(message){
|
||||
if(message && message->firstVia && message->Call_ID && message->CSeq && message->From && message->To){
|
||||
/* Set fd */
|
||||
message->sockfd = e->fd;
|
||||
/* Alert transaction/dialog layer */
|
||||
|
@ -178,6 +176,9 @@ static int tsip_transport_layer_dgram_cb(const tnet_transport_event_t* e)
|
|||
tsk_ragel_state_t state;
|
||||
tsip_message_t *message = tsk_null;
|
||||
const tsip_transport_t *transport = e->callback_data;
|
||||
const char* data_ptr;
|
||||
tsk_size_t data_size;
|
||||
char SigCompBuffer[TSIP_SIGCOMP_MAX_BUFF_SIZE];
|
||||
|
||||
switch(e->type){
|
||||
case event_data: {
|
||||
|
@ -190,7 +191,28 @@ static int tsip_transport_layer_dgram_cb(const tnet_transport_event_t* e)
|
|||
}
|
||||
}
|
||||
|
||||
tsk_ragel_state_init(&state, e->data, e->size);
|
||||
/* === SigComp === */
|
||||
if(TSIP_IS_SIGCOMP_DATA(e->data)){
|
||||
tsk_bool_t is_nack;
|
||||
data_size = tsip_sigcomp_handler_uncompressUDP(transport->stack->sigcomp.handle, "urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a473", e->data, e->size, SigCompBuffer, sizeof(SigCompBuffer), &is_nack);
|
||||
data_ptr = SigCompBuffer;
|
||||
if(data_size){
|
||||
if(is_nack){
|
||||
tnet_transport_send(transport->net_transport, transport->connectedFD, data_ptr, data_size);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
TSK_DEBUG_ERROR("SigComp decompression has failed");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else{
|
||||
data_ptr = e->data;
|
||||
data_size = e->size;
|
||||
}
|
||||
|
||||
tsk_ragel_state_init(&state, data_ptr, data_size);
|
||||
if(tsip_message_parse(&state, &message, tsk_true) == tsk_true
|
||||
&& message->firstVia && message->Call_ID && message->CSeq && message->From && message->To)
|
||||
{
|
||||
|
|
|
@ -737,8 +737,10 @@ int tsip_stack_stop(tsip_stack_handle_t *self)
|
|||
one_failed = tsk_true;
|
||||
}
|
||||
|
||||
/* Remove all SigComp Compartments */
|
||||
TSK_OBJECT_SAFE_FREE(stack->sigcomp.handle);
|
||||
/* Close all SigComp Compartments (do not remove them) */
|
||||
if(stack->sigcomp.handle){
|
||||
tsip_sigcomp_close_all(stack->sigcomp.handle);
|
||||
}
|
||||
|
||||
if(!one_failed){
|
||||
stack->started = tsk_false;
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\tinyNET.lib $(OutDir)\tinyDAV.lib"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinySDP.lib $(OutDir)\tinyNET.lib $(OutDir)\tinyMEDIA.lib $(OutDir)\tinyDAV.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
|
@ -195,6 +195,10 @@
|
|||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\test\test_sessions.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -182,6 +182,10 @@
|
|||
RelativePath="..\..\tinyDAV\include\tinydav\tdav.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\include\tinydav\tdav_win32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\include\tinydav.h"
|
||||
>
|
||||
|
@ -272,6 +276,14 @@
|
|||
<Filter
|
||||
Name="directsound"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\include\tinydav\audio\directsound\tdav_consumer_dsound.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\include\tinydav\audio\directsound\tdav_producer_dsound.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="oss"
|
||||
|
@ -280,6 +292,14 @@
|
|||
<Filter
|
||||
Name="waveapi"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\include\tinydav\audio\waveapi\tdav_consumer_waveapi.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\include\tinydav\audio\waveapi\tdav_producer_waveapi.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -306,6 +326,10 @@
|
|||
RelativePath="..\..\tinyDAV\src\tdav.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\src\tdav_win32.c"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="codecs"
|
||||
>
|
||||
|
@ -388,6 +412,14 @@
|
|||
<Filter
|
||||
Name="directsound"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\src\audio\directsound\tdav_consumer_dsound.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDAV\src\audio\directsound\tdav_producer_dsound.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="oss"
|
||||
|
|
|
@ -25,6 +25,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyDAV", "..\tinyDAV\tinyD
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyRTP", "..\tinyRTP\tinyRTP.vcproj", "{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIGCOMP", "..\tinySIGCOMP\tinySIGCOMP.vcproj", "{76261DC8-25B3-43F4-9FB5-112C4AC0880E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -121,6 +123,16 @@ Global
|
|||
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}.Release|Win32.Build.0 = Release|Win32
|
||||
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Win32.Build.0 = Release|Win32
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -319,7 +319,7 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tinyDEMO\ragel.sh"
|
||||
RelativePath="..\..\tinyDEMO\sigcomp.sn"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(DOUBANGO_HOME)\thirdparties\win32\include";"$(DOUBANGO_HOME)\tinySAK\src""
|
||||
AdditionalIncludeDirectories="..\..\thirdparties\win32\include;..\..\tinySAK\src"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYSIGCOMP_EXPORTS;DEBUG_LEVEL=DEBUG_LEVEL_INFO;_WIN32_WINNT 0x0501"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\thirdparties\win32\include;..\..\thirdparties\win32\include\smc;..\..\tinySIP\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinySDP\include;..\..\tinyMEDIA\include;..\..\tinyHTTP\include;..\..\tinyIPSec\src"
|
||||
AdditionalIncludeDirectories="..\..\thirdparties\win32\include;..\..\thirdparties\win32\include\smc;..\..\tinySIP\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinySDP\include;..\..\tinyMEDIA\include;..\..\tinyHTTP\include;..\..\tinyIPSec\src;..\..\tinySIGCOMP\src"
|
||||
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_WINDOWS;_USRDLL;TINYSIP_EXPORTS;_WIN32_WINNT 0x0501"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -65,7 +65,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib $(OutDir)\tinyHTTP.lib $(OutDir)\tinyIPSec.lib $(OutDir)\tinySDP.lib $(OutDir)\tinyMEDIA.lib"
|
||||
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib $(OutDir)\tinyHTTP.lib $(OutDir)\tinyIPSec.lib $(OutDir)\tinySDP.lib $(OutDir)\tinyMEDIA.lib $(OutDir)\tinySIGCOMP.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
@ -945,6 +945,14 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="sigcomp"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\tinySIP\src\sigcomp\tsip_sigcomp.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="include"
|
||||
|
@ -1519,6 +1527,14 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="sigcomp"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\tinySIP\include\tinysip\sigcomp\tsip_sigcomp.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="ragel"
|
||||
|
|
Loading…
Reference in New Issue