Commit 772945e3 authored by jehan's avatar jehan

first rework

parent d1e35053
......@@ -76,13 +76,40 @@ static float gain_volume_out=1.0;
static bool gain_changed_in = true;
static bool gain_changed_out = true;
const char* aq_format_error(OSStatus status) {
switch (status) {
case kAudioQueueErr_InvalidBuffer: return "kAudioQueueErr_InvalidBuffer";
case kAudioQueueErr_BufferEmpty: return"kAudioQueueErr_BufferEmpty";
case kAudioQueueErr_DisposalPending: return"kAudioQueueErr_DisposalPending";
case kAudioQueueErr_InvalidProperty: return"kAudioQueueErr_InvalidProperty";
case kAudioQueueErr_InvalidPropertySize: return"kAudioQueueErr_InvalidPropertySize";
case kAudioQueueErr_InvalidParameter: return"kAudioQueueErr_InvalidParameter";
case kAudioQueueErr_CannotStart: return"kAudioQueueErr_CannotStart";
case kAudioQueueErr_InvalidDevice: return"kAudioQueueErr_InvalidDevice";
case kAudioQueueErr_BufferInQueue: return"kAudioQueueErr_BufferInQueue";
case kAudioQueueErr_InvalidRunState: return"kAudioQueueErr_InvalidRunState";
case kAudioQueueErr_InvalidQueueType: return"kAudioQueueErr_InvalidQueueType";
case kAudioQueueErr_Permissions: return"kAudioQueueErr_Permissions";
case kAudioQueueErr_InvalidPropertyValue: return"kAudioQueueErr_InvalidPropertyValue";
case kAudioQueueErr_PrimeTimedOut: return"kAudioQueueErr_PrimeTimedOut";
case kAudioQueueErr_CodecNotFound: return"kAudioQueueErr_CodecNotFound";
case kAudioQueueErr_InvalidCodecAccess: return"kAudioQueueErr_InvalidCodecAccess";
case kAudioQueueErr_QueueInvalidated: return"kAudioQueueErr_QueueInvalidated";
case kAudioQueueErr_RecordUnderrun: return"kAudioQueueErr_RecordUnderrun";
case kAudioQueueErr_EnqueueDuringReset: return"kAudioQueueErr_EnqueueDuringReset";
case kAudioQueueErr_InvalidOfflineMode: return"kAudioQueueErr_InvalidOfflineMode";
default:
return "unkown error code";
}
}
#ifdef __ios
#define CFStringRef void *
#define CFRelease(A) {}
#define CFStringGetCString(A, B, LEN, encoding) {}
#define CFStringCreateCopy(A, B) NULL
#define check_aqresult(aq,method) \
if (aq!=0) ms_error("AudioQueue error for %s: ret=%li",method,aq)
if (aq!=0) ms_error("AudioQueue error for %s: ret=%s",method,aq_format_error(aq))
#endif
typedef struct AQData {
......@@ -734,10 +761,11 @@ static void aq_start_r(MSFilter * f)
setupRead(f);
aqresult = AudioQueueStart(d->readQueue, NULL); // start time. NULL means ASAP.
if (aqresult != noErr) {
ms_error("AudioQueueStart -read- %ld", aqresult);
check_aqresult(aqresult,"AudioQueueStart - read");
if (aqresult == noErr) {
d->read_started = TRUE;
}
d->read_started = TRUE;
}
}
......@@ -914,10 +942,11 @@ static void aq_put(MSFilter * f, mblk_t * m)
OSStatus err;
err = AudioQueueStart(d->writeQueue, NULL // start time. NULL means ASAP.
);
if (err != noErr) {
ms_error("AudioQueueStart -write- %ld", err);
}
d->write_started = TRUE;
check_aqresult(err, "AudioQueueStart -write-");
if (err == noErr) {
d->write_started = TRUE;
}
}
}
......
......@@ -461,10 +461,12 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
/* create ticker */
stream->ticker=ms_ticker_new();
ms_ticker_stop(stream->ticker); /*to make sure all filters are started after preprocessed this is very useful for filter sharing resource in both filter graph*/
ms_ticker_set_name(stream->ticker,"Audio MSTicker");
ms_ticker_set_priority(stream->ticker,__ms_get_default_prio(FALSE));
ms_ticker_attach(stream->ticker,stream->soundread);
ms_ticker_attach(stream->ticker,stream->rtprecv);
ms_ticker_start(stream->ticker);
stream->start_time=ms_time(NULL);
stream->is_beginning=TRUE;
......
This diff is collapsed.
......@@ -48,6 +48,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if defined(__ios) || defined (ANDROID)
#ifdef __ios
#import <UIKit/UIKit.h>
#include <AudioToolbox/AudioToolbox.h>
#endif
extern void ms_set_video_stream(VideoStream* video);
#ifdef HAVE_X264
......@@ -176,9 +177,36 @@ const char *usage="mediastream --local <port> --remote <ip:port> \n"
"[ --netsim-bandwidth <bandwidth limit in bits/s> (simulates a network download bandwidth limit)\n"
;
#if TARGET_OS_IPHONE
int g_argc;
char** g_argv;
static int _main(int argc, char * argv[]);
static void* apple_main(void* data) {
_main(g_argc,g_argv);
return NULL;
}
int main(int argc, char * argv[]) {
pthread_t main_thread;
g_argc=argc;
g_argv=argv;
pthread_create(&main_thread,NULL,apple_main,NULL);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int value = UIApplicationMain(0, nil, nil, nil);
[pool release];
return value;
cond=0;
pthread_join(main_thread,NULL);
return 0;
}
static int _main(int argc, char * argv[])
#endif
#if !defined(ANDROID) && !defined(__APPLE__)
#if !__APPLE__ && !ANDROID
int main(int argc, char * argv[])
#endif
#if !ANDROID && !TARGET_OS_MACX
{
MediastreamDatas* args;
cond = 1;
......@@ -188,6 +216,15 @@ int main(int argc, char * argv[])
if (!parse_args(argc, argv, args))
return 0;
/* if (!args->capture_card || strcmp("AU: Audio Unit Fast Receiver", args->capture_card) == 0) {
AudioSessionInitialize(NULL,NULL,NULL,NULL);
if (!AudioSessionSetActive(true)) {
ms_fatal ("Cannot activate audio session");
};
OSStatus auresult;
UInt32 audioCategory=kAudioSessionCategory_PlayAndRecord;
auresult =AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory);
}*/
setup_media_streams(args);
if (args->eq)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment