Commit f7226012 authored by Ghislain MARY's avatar Ghislain MARY

Merge branch 'master' of git.linphone.org:mediastreamer2 into dev_dshow

parents ce3e553d e72a7987
......@@ -118,15 +118,15 @@
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
Optimization="2"
AdditionalIncludeDirectories="..\..\..\..\ortp\include;..\..\..\include"
PreprocessorDefinitions="WIN32;_CONSOLE;VIDEO_ENABLED"
PreprocessorDefinitions="WIN32;_CONSOLE;VIDEO_ENABLED;NDEBUG"
MinimalRebuild="true"
BasicRuntimeChecks="0"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
DebugInformationFormat="0"
CompileAs="1"
/>
<Tool
......@@ -140,10 +140,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="mediastreamer2.lib oRTP.lib"
AdditionalDependencies="mediastreamer2.lib ortp.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;..\..\..\..\ortp\build\win32native\$(ConfigurationName)&quot;"
GenerateDebugInformation="true"
AdditionalLibraryDirectories="&quot;..\$(OutDir)&quot;;&quot;$(OutDir)&quot;;&quot;..\..\..\..\oRTP\build\win32native\$(ConfigurationName)&quot;"
GenerateDebugInformation="false"
SubSystem="1"
TargetMachine="1"
/>
......
......@@ -8,7 +8,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mediastreamer2", "mediastre
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mediastream", "mediastream\mediastream.vcproj", "{F158434B-A7BD-4683-87FD-33AF6B450612}"
ProjectSection(ProjectDependencies) = postProject
{4A07BB2B-F56E-4F1B-A719-D28B782AC128} = {4A07BB2B-F56E-4F1B-A719-D28B782AC128}
{4A07BB2B-F56E-4F1B-A729-D28B782AC128} = {4A07BB2B-F56E-4F1B-A729-D28B782AC128}
{8A4A1340-5B83-4698-8F2A-B8DCCA0C3285} = {8A4A1340-5B83-4698-8F2A-B8DCCA0C3285}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "oRTP", "..\..\..\ortp\build\win32native\oRTP.vcproj", "{4A07BB2B-F56E-4F1B-A719-D28B782AC128}"
......
......@@ -75,6 +75,8 @@
ProgramDatabaseFile="$(OutDir)/mediastreamer2.pdb"
GenerateMapFile="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(IntDir)/mediastreamer2.lib"
......@@ -129,8 +131,9 @@
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\include;..\..\..\oRTP\include;.;&quot;..\..\..\linphone-deps\include&quot;;&quot;..\..\..\linphone-deps\include\msvc&quot;"
PreprocessorDefinitions="__STDC_CONSTANT_MACROS;HAVE_LIBSWSCALE_SWSCALE_H;HAVE_LIBAVCODEC_AVCODEC_H;HAVE_SPEEXDSP;HAVE_DIRECTSHOW;VIDEO_ENABLED;ORTP_INET6;WIN32;_DEBUG;_WINDOWS;_USRDLL;MEDIASTREAMER2_EXPORTS;WINDOW_NATIVE;_CRT_SECURE_NO_DEPRECATE;MS2_INTERNAL"
PreprocessorDefinitions="__STDC_CONSTANT_MACROS;HAVE_LIBSWSCALE_SWSCALE_H;HAVE_LIBAVCODEC_AVCODEC_H;HAVE_SPEEXDSP;HAVE_DIRECTSHOW;VIDEO_ENABLED;ORTP_INET6;WIN32;_DEBUG;_WINDOWS;_USRDLL;MEDIASTREAMER2_EXPORTS;WINDOW_NATIVE;_CRT_SECURE_NO_DEPRECATE;_TRUE_TIME;MS2_INTERNAL;MS2_FILTERS"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
......@@ -150,13 +153,13 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="avcodec.lib libvpx.a swscale.lib avutil.lib ogg.lib libtheora.lib vfw32.lib Ws2_32.lib Winmm.lib ortp.lib libspeex.a libspeexdsp.a libgsm.a libgcc.a"
AdditionalDependencies="avcodec.lib libvpx.a swscale.lib avutil.lib libtheora.lib vfw32.lib Ws2_32.lib Winmm.lib ortp.lib libspeex.a libspeexdsp.a libgsm.a libgcc.a"
OutputFile="$(IntDir)/mediastreamer2.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\linphone-deps\lib&quot;;&quot;..\..\..\oRTP\build\win32native\$(OutDir)&quot;"
AdditionalLibraryDirectories="&quot;..\..\..\linphone-deps\lib&quot;;&quot;..\..\..\linphone-deps\lib\msvc&quot;;&quot;..\..\..\ortp\build\win32native\$(IntDir)&quot;"
IgnoreAllDefaultLibraries="false"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
GenerateDebugInformation="false"
ProgramDatabaseFile="$(OutDir)/mediastreamer2.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
......
......@@ -145,7 +145,7 @@ case $host in
i386-apple*|armv6-apple*|armv7-apple*|armv7s-apple*)
ios_found=yes
;;
x86_64-apple*)
x86_64-apple*|i686-apple*)
macosx_found=yes
;;
*mingw32ce)
......@@ -717,12 +717,22 @@ fi
AC_PATH_PROG(PCAP,pcap-config,false)
AM_CONDITIONAL(HAVE_PCAP, test $PCAP != false)
if test $PCAP != false ; then
PCAP_LIBS=`pcap-config --libs`
PCAP_CFLAGS=`pcap-config --cflags`
PCAP_CFLAGS="$PCAP_CFLAGS -DHAVE_PCAP"
AC_SUBST(PCAP_LIBS)
AC_SUBST(PCAP_CFLAGS)
AC_ARG_ENABLE(pcap,
[AS_HELP_STRING([--enable-pcap], [Enable pcap library (default=no)])],
[case "${enableval}" in
yes) enable_pcap=yes ;;
no) enable_pcap=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pcap) ;;
esac], [enable_pcap=no])
AM_CONDITIONAL(ENABLE_PCAP, test x$enable_pcap = xyes)
if test x$enable_pcap == xyes ; then
if test $PCAP != false ; then
PCAP_LIBS=`pcap-config --libs`
PCAP_CFLAGS=`pcap-config --cflags`
PCAP_CFLAGS="$PCAP_CFLAGS -DHAVE_PCAP"
AC_SUBST(PCAP_LIBS)
AC_SUBST(PCAP_CFLAGS)
fi
fi
......
......@@ -333,6 +333,7 @@ struct _VideoStream
OrtpZrtpContext *ortpZrtpContext;
srtp_t srtp_session;
MSBitrateController *rc;
bool_t prepare_ongoing;
};
typedef struct _VideoStream VideoStream;
......
......@@ -558,6 +558,7 @@ enum _MSFilterInterfaceId{
MSFilterVideoDecoderInterface,
MSFilterVideoCaptureInterface,
MSFilterDecoderInterface,
MSFilterVideoEncoderInterface,
};
typedef enum _MSFilterInterfaceId MSFilterInterfaceId;
......
......@@ -143,4 +143,11 @@ typedef enum _MSPlayerState MSPlayerState;
#define MS_DECODER_HAVE_PLC \
MS_FILTER_METHOD(MSFilterDecoderInterface,0,int)
/** Interface definitions for video encoders */
#define MS_VIDEO_ENCODER_HAS_BUILTIN_CONVERTER \
MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 0, bool_t)
/* request a video-fast-update (=I frame for H263,MP4V-ES) to a video encoder*/
#define MS_VIDEO_ENCODER_REQ_VFU \
MS_FILTER_METHOD_NO_ARG(MSFilterVideoEncoderInterface, 1)
#endif
......@@ -339,6 +339,7 @@ MS2_PUBLIC bool_t ms_video_update_average_fps(MSAverageFPS* afps, uint32_t curre
#define MS_FILTER_GET_FPS MS_FILTER_BASE_METHOD(105,float)
/* request a video-fast-update (=I frame for H263,MP4V-ES) to a video encoder*/
/* DEPRECATED: Use MS_VIDEO_ENCODER_REQ_VFU instead */
#define MS_FILTER_REQ_VFU MS_FILTER_BASE_METHOD_NO_ARG(106)
#endif
......@@ -223,6 +223,7 @@ MS2_PUBLIC const char *ms_web_cam_get_string_id(MSWebCam *obj);
/*specific methods for static image:*/
MS2_PUBLIC void ms_static_image_set_default_image(const char *path);
MS2_PUBLIC const char *ms_static_image_get_default_image();
/** method for the "nowebcam" filter */
#define MS_STATIC_IMAGE_SET_IMAGE \
......
......@@ -108,7 +108,7 @@ AudioRecordImpl *AudioRecordImpl::sImpl=NULL;
AudioRecordImpl::AudioRecordImpl(Library *lib) :
// By default, try to load Android 2.3 symbols
mCtorBeforeAPI17(lib,"_ZN7android11AudioRecordC1EijijijPFviPvS1_ES1_ii"),
mCtor(lib, ""),
mCtor(lib, "_ZN7android11AudioRecordC1E14audio_source_tj14audio_format_tjiPFviPvS3_ES3_ii"), // 4.2 symbol
mDtor(lib,"_ZN7android11AudioRecordD1Ev"),
mInitCheck(lib,"_ZNK7android11AudioRecord9initCheckEv"),
mStop(lib,"_ZN7android11AudioRecord4stopEv"),
......@@ -132,9 +132,6 @@ AudioRecordImpl::AudioRecordImpl(Library *lib) :
}
// Then try some Android 4.2 symbols if still not found
if (!mCtorBeforeAPI17.isFound()) {
mCtor.load(lib, "_ZN7android11AudioRecordC1E14audio_source_tj14audio_format_tjiPFviPvS3_ES3_ii");
}
if (!mGetMinFrameCount.isFound()) {
mGetMinFrameCount.load(lib, "_ZN7android11AudioRecord16getMinFrameCountEPij14audio_format_tj");
}
......
......@@ -31,6 +31,22 @@ status_t AudioSystem::getOutputSamplingRate(int *rate, int streamType){
return AudioSystemImpl::get()->mGetOutputSamplingRate.invoke(rate,streamType);
}
status_t AudioSystem::getOutputFrameCount(int *frameCount, audio_stream_type_t streamType) {
return AudioSystemImpl::get()->mGetOutputFrameCount.invoke(frameCount, streamType);
}
status_t AudioSystem::getOutputFrameCount(int *frameCount, int streamType) {
return AudioSystemImpl::get()->mGetOutputFrameCount.invoke(frameCount, streamType);
}
status_t AudioSystem::getOutputLatency(uint32_t *latency, audio_stream_type_t streamType) {
return AudioSystemImpl::get()->mGetOutputLatency.invoke(latency, streamType);
}
status_t AudioSystem::getOutputLatency(uint32_t *latency, int streamType) {
return AudioSystemImpl::get()->mGetOutputLatency.invoke(latency, streamType);
}
status_t AudioSystem::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs){
return AudioSystemImpl::get()->mSetParameters.invoke(ioHandle,keyValuePairs);
}
......@@ -48,19 +64,61 @@ audio_io_handle_t AudioSystem::getInput(audio_source_t inputSource,
AudioSystemImpl::AudioSystemImpl(Library *lib) :
// By default, try to load Android 2.3 symbols
mGetOutputSamplingRate(lib,"_ZN7android11AudioSystem21getOutputSamplingRateEPii"),
mGetOutputFrameCount(lib, "_ZN7android11AudioSystem19getOutputFrameCountEPii"),
mGetOutputLatency(lib, "_ZN7android11AudioSystem16getOutputLatencyEPji"),
mSetParameters(lib,"_ZN7android11AudioSystem13setParametersEiRKNS_7String8E"){
//mGetInput(lib,"_ZN7android11AudioSystem8getInputEijjjNS0_18audio_in_acousticsE"){
// Try some Android 4.1 symbols if not found
if (!mGetOutputSamplingRate.isFound()) {
mGetOutputSamplingRate.load(lib, "_ZN7android11AudioSystem21getOutputSamplingRateEPi19audio_stream_type_t");
}
if (!mGetOutputFrameCount.isFound()) {
mGetOutputFrameCount.load(lib, "_ZN7android11AudioSystem19getOutputFrameCountEPi19audio_stream_type_t");
}
if (!mGetOutputLatency.isFound()) {
mGetOutputLatency.load(lib, "_ZN7android11AudioSystem16getOutputLatencyEPj19audio_stream_type_t");
}
}
bool AudioSystemImpl::init(Library *lib){
AudioSystemImpl *impl=new AudioSystemImpl(lib);
int samplingRate;
int frameCount;
uint32_t latency;
status_t err;
bool buggyAndroid = false;
if (!impl->mGetOutputSamplingRate.isFound()) goto fail;
if (!impl->mGetOutputFrameCount.isFound()) goto fail;
if (!impl->mGetOutputLatency.isFound()) goto fail;
if (!impl->mSetParameters.isFound()) goto fail;
//if (!impl->mGetInput.isFound()) goto fail;
err = impl->mGetOutputSamplingRate.invoke(&samplingRate, AUDIO_STREAM_VOICE_CALL);
if (err == 0) err = impl->mGetOutputFrameCount.invoke(&frameCount, AUDIO_STREAM_VOICE_CALL);
if (err == 0) err = impl->mGetOutputLatency.invoke(&latency, AUDIO_STREAM_VOICE_CALL);
if (err == 0) {
ms_message("AUDIO_STREAM_VOICE_CALL characteristics: SamplingRate=%d, FrameCount=%d, Latency=%u", samplingRate, frameCount, latency);
} else {
ms_error("Unable to get AUDIO_STREAM_VOICE_CALL characteristics");
}
if ((frameCount > 8192) || (latency > 200)) buggyAndroid = true;
err = impl->mGetOutputSamplingRate.invoke(&samplingRate, AUDIO_STREAM_DEFAULT);
if (err == 0) err = impl->mGetOutputFrameCount.invoke(&frameCount, AUDIO_STREAM_DEFAULT);
if (err == 0) err = impl->mGetOutputLatency.invoke(&latency, AUDIO_STREAM_DEFAULT);
if (err == 0) {
ms_message("AUDIO_STREAM_DEFAULT characteristics: SamplingRate=%d, FrameCount=%d, Latency=%u", samplingRate, frameCount, latency);
} else {
ms_error("Unable to get AUDIO_STREAM_DEFAULT characteristics");
}
if (buggyAndroid) goto fail;
sImpl=impl;
return true;
fail:
delete impl;
return false;
......
......@@ -107,6 +107,9 @@ public:
// DEPRECATED
static status_t getOutputFrameCount(int* frameCount, int stream = AUDIO_STREAM_DEFAULT);
// DEPRECATED
static status_t getOutputLatency(uint32_t* latency, int stream = AUDIO_STREAM_DEFAULT);
static bool routedToA2dpOutput(audio_stream_type_t streamType);
static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount,
......@@ -246,6 +249,8 @@ public:
return sImpl;
}
Function2<status_t,int*,int> mGetOutputSamplingRate;
Function2<status_t, int *, int> mGetOutputFrameCount;
Function2<status_t, uint32_t *, int> mGetOutputLatency;
Function2<status_t,audio_io_handle_t,const String8 &> mSetParameters;
//Function6<audio_io_handle_t,audio_source_t,uint32_t,audio_format_t,uint32_t,audio_in_acoustics_t,int> mGetInput;
private:
......
......@@ -59,6 +59,13 @@ The BSD license below is for the original work.
#include "mediastreamer2/mssndcard.h"
#include "mediastreamer2/msfilter.h"
#if __LP64__
#define UINT32_PRINTF "u"
#define UINT32_X_PRINTF "x"
#else
#define UINT32_PRINTF "lu"
#define UINT32_X_PRINTF "lx"
#endif
MSFilter *ms_au_read_new(MSSndCard *card);
MSFilter *ms_au_write_new(MSSndCard *card);
......@@ -81,7 +88,7 @@ static void show_format(const char *name, AudioStreamBasicDescription * deviceFo
ms_debug("mChannelsPerFrame = %ld", deviceFormat->mChannelsPerFrame);
ms_debug("mBytesPerFrame = %ld", deviceFormat->mBytesPerFrame);
ms_debug("mBitsPerChannel = %ld", deviceFormat->mBitsPerChannel);
ms_message("Format for [%s] rate [%g] channels [%d]", outName,deviceFormat->mSampleRate,deviceFormat->mChannelsPerFrame);
ms_message("Format for [%s] rate [%g] channels [%"UINT32_PRINTF"]", outName,deviceFormat->mSampleRate,deviceFormat->mChannelsPerFrame);
}
......@@ -175,7 +182,7 @@ static MSSndCard *ca_card_new(const char *name, const char * uidname, AudioDevic
MSSndCard *card = ms_snd_card_new(&ca_card_desc);
AudioStreamBasicDescription format;
AuCard *d = (AuCard *) card->data;
unsigned int slen;
UInt32 slen;
int err;
d->uidname = ms_strdup(uidname);
......@@ -208,7 +215,7 @@ static MSSndCard *ca_card_new(const char *name, const char * uidname, AudioDevic
}
static bool_t check_card_capability(AudioDeviceID id, bool_t is_input, char * devname, char *uidname, size_t name_len){
unsigned int slen=name_len;
UInt32 slen=name_len;
CFStringRef dUID=NULL;
bool_t ret=FALSE;
OSStatus err;
......@@ -226,7 +233,7 @@ static bool_t check_card_capability(AudioDeviceID id, bool_t is_input, char * de
,devname);
/*int err =AudioDeviceGetProperty(id, 0, is_input, kAudioDevicePropertyDeviceName, &slen,devname);*/
if (err != kAudioHardwareNoError) {
ms_error("get kAudioDevicePropertyDeviceName error %d", err);
ms_error("get kAudioDevicePropertyDeviceName error %"UINT32_PRINTF, err);
return FALSE;
}
theAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
......@@ -238,7 +245,7 @@ static bool_t check_card_capability(AudioDeviceID id, bool_t is_input, char * de
,&slen);
/*err =AudioDeviceGetPropertyInfo(id, 0, is_input, kAudioDevicePropertyStreamConfiguration, &slen, &writable);*/
if (err != kAudioHardwareNoError) {
ms_error("get kAudioDevicePropertyDeviceName error %d", err);
ms_error("get kAudioDevicePropertyDeviceName error %"UINT32_PRINTF, err);
return FALSE;
}
......@@ -253,7 +260,7 @@ static bool_t check_card_capability(AudioDeviceID id, bool_t is_input, char * de
,buflist);
/*err = AudioDeviceGetProperty(id, 0, is_input, kAudioDevicePropertyStreamConfiguration, &slen, buflist);*/
if (err != kAudioHardwareNoError) {
ms_error("get kAudioDevicePropertyDeviceName error %d", err);
ms_error("get kAudioDevicePropertyDeviceName error %"UINT32_PRINTF, err);
ms_free(buflist);
return FALSE;
}
......@@ -278,7 +285,7 @@ static bool_t check_card_capability(AudioDeviceID id, bool_t is_input, char * de
,&dUID);
//err =AudioDeviceGetProperty(id, 0, is_input, kAudioDevicePropertyDeviceUID, &slen,&dUID);
if (err != kAudioHardwareNoError) {
ms_error("get kAudioHardwarePropertyDevices error %d", err);
ms_error("get kAudioHardwarePropertyDevices error %"UINT32_PRINTF, err);
return FALSE;
}
CFStringGetCString(dUID, uidname, name_len,CFStringGetSystemEncoding());
......@@ -310,7 +317,7 @@ static void au_card_detect(MSSndCardManager * m)
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &slen,
&writable);*/
if (err != kAudioHardwareNoError) {
ms_error("get kAudioHardwarePropertyDevices error %i", err);
ms_error("get kAudioHardwarePropertyDevices error %"UINT32_PRINTF, err);
return;
}
AudioDeviceID devices[slen / sizeof(AudioDeviceID)];
......@@ -323,7 +330,7 @@ static void au_card_detect(MSSndCardManager * m)
/*err =
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &slen, devices);*/
if (err != kAudioHardwareNoError) {
ms_error("get kAudioHardwarePropertyDevices error %i", err);
ms_error("get kAudioHardwarePropertyDevices error %"UINT32_PRINTF, err);
return;
}
/*first, add Default AudioUnit
......@@ -376,7 +383,7 @@ static OSStatus readRenderProc(void *inRefCon,
err=AudioUnitRender(d->common.au, inActionFlags, inTimeStamp, inBusNumber, inNumFrames, &lreadAudioBufferList);
if (err!=noErr){
ms_error("AudioUnitRender() for read returned [%i] %s %s",err,GetMacOSStatusErrorString(err),GetMacOSStatusCommentString(err));
ms_error("AudioUnitRender() for read returned [%"UINT32_PRINTF"] %s %s",err,GetMacOSStatusErrorString(err),GetMacOSStatusCommentString(err));
return 0;
}
//ms_message("Got input buffer of size %i",lreadAudioBufferList.mBuffers[0].mDataByteSize);
......@@ -400,11 +407,11 @@ static OSStatus writeRenderProc(void *inRefCon,
AUWrite *d=(AUWrite*)inRefCon;
int read;
if (ioData->mNumberBuffers!=1) ms_warning("writeRenderProc: %i buffers",ioData->mNumberBuffers);
if (ioData->mNumberBuffers!=1) ms_warning("writeRenderProc: %"UINT32_PRINTF" buffers",ioData->mNumberBuffers);
ms_mutex_lock(&d->common.mutex);
read=ms_bufferizer_read(d->buffer,ioData->mBuffers[0].mData,ioData->mBuffers[0].mDataByteSize);
if (ms_bufferizer_get_avail(d->buffer) >10*inNumFrames*2) {
ms_message("we are late, bufferizer sise is [%i] bytes in framezize is [%i] bytes"
ms_message("we are late, bufferizer sise is [%i] bytes in framezize is [%"UINT32_PRINTF"] bytes"
,ms_bufferizer_get_avail(d->buffer)
,inNumFrames*2);
ms_bufferizer_flush(d->buffer);
......@@ -412,7 +419,7 @@ static OSStatus writeRenderProc(void *inRefCon,
ms_mutex_unlock(&d->common.mutex);
if (read==0){
ms_warning("Silence inserted in audio output unit (%i bytes)",ioData->mBuffers[0].mDataByteSize);
ms_warning("Silence inserted in audio output unit (%"UINT32_PRINTF" bytes)",ioData->mBuffers[0].mDataByteSize);
memset(ioData->mBuffers[0].mData,0,ioData->mBuffers[0].mDataByteSize);
}
return 0;
......@@ -444,7 +451,7 @@ static int audio_unit_open(AUCommon *d, bool_t is_read){
result = OpenAComponent(comp, &d->au);
if(result != noErr)
{
ms_message("Cannot open audio component %x", result);
ms_message("Cannot open audio component %"UINT32_X_PRINTF, result);
return -1;
}
......@@ -532,7 +539,7 @@ static int audio_unit_open(AUCommon *d, bool_t is_read){
input_bus,
&numFrames,
&param));
ms_message("Number of frames per buffer = %i", numFrames);
ms_message("Number of frames per buffer = %"UINT32_PRINTF, numFrames);
AURenderCallbackStruct cbs;
......@@ -557,7 +564,7 @@ static int audio_unit_open(AUCommon *d, bool_t is_read){
result = AudioUnitInitialize(d->au);
if(result != noErr)
{
ms_error("failed to AudioUnitInitialize %i , is_read=%i", result,(int)is_read);
ms_error("failed to AudioUnitInitialize %"UINT32_PRINTF" , is_read=%i", result,(int)is_read);
return -1;
}
......
......@@ -15,8 +15,9 @@
@private
CGLPixelFormatObj cglPixelFormat;
CGLContextObj cglContext;
NSRecursiveLock* lock;
CGRect prevBounds;
NSRecursiveLock* lock;
CGRect prevBounds;
CGSize sourceSize;
}
- (void)resizeToWindow:(NSWindow *)window;
......@@ -115,7 +116,7 @@
CGLSetCurrentContext(cglContext);
CGLLockContext(cglContext);
if (!NSEqualRects(prevBounds, [self bounds])) {
if (!CGRectEqualToRect(prevBounds, [self bounds])) {
prevBounds = [self bounds];
ogl_display_set_size(display_helper, prevBounds.size.width, prevBounds.size.height);
}
......@@ -151,8 +152,14 @@
@end
@interface OSXDisplay : NSObject
@interface OSXDisplay : NSObject {
@private
BOOL closeWindow;
NSWindow* window;
NSView* view;
CALayer* layer;
CAMsGLLayer* glLayer;
}
@property (assign) BOOL closeWindow;
@property (nonatomic, retain) NSWindow* window;
@property (nonatomic, retain) NSView* view;
......@@ -359,16 +366,16 @@ static int osx_gl_set_vsize(MSFilter* f, void* arg) {
static int osx_gl_get_native_window_id(MSFilter* f, void* arg) {
OSXDisplay* thiz = (OSXDisplay*) f->data;
unsigned long *winId=(unsigned long*)arg;
unsigned long *winId = (unsigned long*)arg;
if(thiz != nil) {
if(thiz->window != nil) {
*winId = (unsigned long)thiz->window;
}
if(thiz->view != nil) {
*winId = (unsigned long)thiz->view;
}
if(thiz->layer != nil) {
*winId = (unsigned long)thiz->layer;
if(thiz.window != nil) {
*winId = (unsigned long)thiz.window;
} else if(thiz.view != nil) {
*winId = (unsigned long)thiz.view;
} else if(thiz.layer != nil) {
*winId = (unsigned long)thiz.layer;
} else {
*winId = 0;
}
}
return 0;
......
......@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define B64_NO_NAMESPACE
#endif
#include "ortp/b64.h"
#include "ortp/stun.h"
static const int default_dtmf_duration_ms=100; /*in milliseconds*/
......@@ -34,6 +35,7 @@ struct SenderData {
uint32_t tsoff;
uint32_t last_ts;
int64_t last_sent_time;
int64_t last_stun_sent_time;
uint32_t skip_until;
int rate;
int nchannels;
......@@ -68,6 +70,7 @@ static void sender_init(MSFilter * f)
d->relay_session_id_size=0;
d->last_rsi_time=0;
d->last_sent_time=-1;
d->last_stun_sent_time = -1;
d->last_ts=0;
f->data = d;
}
......@@ -331,6 +334,7 @@ static void sender_process(MSFilter * f)
rtp_session_send_rtcp_APP(s,0,"RSID",(const uint8_t *)d->relay_session_id,d->relay_session_id_size);
d->last_rsi_time=f->ticker->time;
}
ms_filter_lock(f);
im = ms_queue_get(f->inputs[0]);
do {
......@@ -362,6 +366,25 @@ static void sender_process(MSFilter * f)
}
}
}while ((im = ms_queue_get(f->inputs[0])) != NULL);
if (d->last_sent_time == -1) {
if ((d->last_stun_sent_time == -1) || ((f->ticker->time - d->last_stun_sent_time) >= 500)) {
d->last_stun_sent_time = f->ticker->time;
}
if (d->last_stun_sent_time == f->ticker->time) {
StunMessage msg;
struct sockaddr_in *destaddr = (struct sockaddr_in *)&s->rtp.rem_addr;
char buf[STUN_MAX_MESSAGE_SIZE];
int len = STUN_MAX_MESSAGE_SIZE;
memset(&msg, 0, sizeof(StunMessage));
stunBuildReqSimple(&msg, NULL, FALSE, FALSE, 1);
len = stunEncodeMessage(&msg, buf, len, NULL);
if (len > 0) {
sendMessage(s->rtp.socket, buf, len, htonl(destaddr->sin_addr.s_addr), htons(destaddr->sin_port));
}
}
}
ms_filter_unlock(f);
}
......
......@@ -1977,3 +1977,7 @@ void ms_static_image_set_default_image(const char *path){
if (path)
def_image=ms_strdup(path);
}
const char *ms_static_image_get_default_image(){
return def_image;
}
......@@ -899,6 +899,7 @@ static MSFilterMethod methods[]={
{ MS_FILTER_GET_BITRATE , enc_get_br },
{ MS_FILTER_SET_MTU , enc_set_mtu },
{ MS_FILTER_REQ_VFU , enc_req_vfu },
{ MS_VIDEO_ENCODER_REQ_VFU, enc_req_vfu },
{ 0 , NULL }
};
......
......@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msinterfaces.h"
#include "mediastreamer2/msvideo.h"
#include "mediastreamer2/msrtp.h"
#include "mediastreamer2/msvideoout.h"
......@@ -163,6 +164,7 @@ static void stop_preload_graph(VideoStream *stream){
ms_filter_destroy(stream->voidsink);
ms_filter_destroy(stream->rtprecv);
stream->voidsink=stream->rtprecv=NULL;
stream->prepare_ongoing = FALSE;
}
void video_stream_iterate(VideoStream *stream){
......@@ -314,6 +316,7 @@ static void configure_video_source(VideoStream *stream){
MSVideoSize vsize,cam_vsize;
float fps=15;
MSPixFmt format;
bool_t encoder_has_builtin_converter = FALSE;
/* transmit orientation to source filter */
ms_filter_call_method(stream->source,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&stream->device_orientation);
......@@ -323,6 +326,7 @@ static void configure_video_source(VideoStream *stream){
video_stream_set_native_preview_window_id(stream, stream->preview_window_id);
}
ms_filter_call_method(stream->encoder, MS_VIDEO_ENCODER_HAS_BUILTIN_CONVERTER, &encoder_has_builtin_converter);
ms_filter_call_method(stream->encoder,MS_FILTER_GET_VIDEO_SIZE,&vsize);
vsize=get_compatible_size(vsize,stream->sent_vsize);
ms_filter_call_method(stream->source,MS_FILTER_SET_VIDEO_SIZE,&vsize);
......@@ -353,16 +357,20 @@ static void configure_video_source(VideoStream *stream){
/* get the output format for webcam reader */
ms_filter_call_method(stream->source,MS_FILTER_GET_PIX_FMT,&format);
if (format==MS_MJPEG){
stream->pixconv=ms_filter_new(MS_MJPEG_DEC_ID);
}else{
stream->pixconv = ms_filter_new(MS_PIX_CONV_ID);
/*set it to the pixconv */
ms_filter_call_method(stream->pixconv,MS_FILTER_SET_PIX_FMT,&format);
ms_filter_call_method(stream->pixconv,MS_FILTER_SET_VIDEO_SIZE,&cam_vsize);
if (encoder_has_builtin_converter == TRUE) {
ms_filter_call_method(stream->encoder, MS_FILTER_SET_PIX_FMT, &format);
} else {
if (format==MS_MJPEG){
stream->pixconv=ms_filter_new(MS_MJPEG_DEC_ID);
}else{
stream->pixconv = ms_filter_new(MS_PIX_CONV_ID);
/*set it to the pixconv */
ms_filter_call_method(stream->pixconv,MS_FILTER_SET_PIX_FMT,&format);
ms_filter_call_method(stream->pixconv,MS_FILTER_SET_VIDEO_SIZE,&cam_vsize);
}
stream->sizeconv=ms_filter_new(MS_SIZE_CONV_ID);
ms_filter_call_method(stream->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&vsize);
}
stream->sizeconv=ms_filter_new(MS_SIZE_CONV_ID);
ms_filter_call_method(stream->sizeconv,MS_FILTER_SET_VIDEO_SIZE,&vsize);
if (stream->rc){
ms_bitrate_controller_destroy(stream->rc);
stream->rc=NULL;
......@@ -419,6 +427,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
rtp_session_set_rtp_socket_send_buffer_size(stream->session,socket_buf_size);
if (stream->dir==VideoStreamSendRecv || stream->dir==VideoStreamSendOnly){
MSConnectionHelper ch;
/*plumb the outgoing stream */
if (rem_rtp_port>0) ms_filter_call_method(stream->rtpsend,MS_RTP_SEND_SET_SESSION,stream->session);
......@@ -447,12 +456,18 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
}
configure_video_source (stream);
/* and then connect all */
ms_filter_link (stream->source, 0, stream->pixconv, 0);
ms_filter_link (stream->pixconv, 0, stream->sizeconv, 0);
ms_filter_link (stream->sizeconv, 0, stream->tee, 0);
ms_filter_link (stream->tee, 0 ,stream->encoder, 0 );
ms_filter_link (stream->encoder,0, stream->rtpsend,0);
/* and then connect all */
ms_connection_helper_start(&ch);
ms_connection_helper_link(&ch, stream->source, -1, 0);
if (stream->pixconv) {
ms_connection_helper_link(&ch, stream->pixconv, 0, 0);
}
if (stream->sizeconv) {
ms_connection_helper_link(&ch, stream->sizeconv, 0, 0);
}
ms_connection_helper_link(&ch, stream->tee, 0, 0);
ms_connection_helper_link(&ch, stream->encoder, 0, 0);
ms_connection_helper_link(&ch, stream->rtpsend, 0, -1);
if (stream->output2){
if (stream->preview_window_id!=0){
ms_filter_call_method(stream->output2, MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID,&stream->preview_window_id);
......@@ -532,6 +547,12 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
if (stream->tee!=NULL && stream->output!=NULL && stream->output2==NULL)
ms_filter_link(stream->tee,1,stream->output,1);
}
if (stream->dir == VideoStreamSendOnly) {
stream->rtprecv = ms_filter_new (MS_RTP_RECV_ID);
ms_filter_call_method(stream->rtprecv, MS_RTP_RECV_SET_SESSION, stream->session);
stream->voidsink = ms_filter_new(MS_VOID_SINK_ID);
ms_filter_link(stream->rtprecv, 0, stream->voidsink, 0);
}
/* create the ticker */
if (stream->ticker==NULL) start_ticker(stream);
......@@ -545,6 +566,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
}
void video_stream_prepare_video(VideoStream *stream){
stream->prepare_ongoing = TRUE;
video_stream_unprepare_video(stream);
stream->rtprecv=ms_filter_new(MS_RTP_RECV_ID);
rtp_session_set_payload_type(stream->session,0);
......@@ -608,7 +630,7 @@ void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){
void video_stream_send_vfu(VideoStream *stream){
if (stream->encoder)
ms_filter_call_method_noarg(stream->encoder,MS_FILTER_REQ_VFU);
ms_filter_call_method_noarg(stream->encoder, MS_VIDEO_ENCODER_REQ_VFU);
}
void
......@@ -617,7 +639,7 @@ video_stream_stop (VideoStream * stream)
stream->eventcb = NULL;
stream->event_pointer = NULL;
if (stream->ticker){
if (stream->voidsink) {
if (stream->prepare_ongoing == TRUE) {
stop_preload_graph(stream);
} else {
if (stream->source)
......@@ -632,16 +654,25 @@ video_stream_stop (VideoStream * stream)
rtp_stats_display(rtp_session_get_stats(stream->session),"Video session's RTP statistics");
if (stream->source){
ms_filter_unlink(stream->source,0,stream->pixconv,0);
ms_filter_unlink (stream->pixconv, 0, stream->sizeconv, 0);
ms_filter_unlink (stream->sizeconv, 0, stream->tee, 0);
ms_filter_unlink(stream->tee,0,stream->encoder,0);
ms_filter_unlink(stream->encoder, 0, stream->rtpsend,0);
MSConnectionHelper ch;
ms_connection_helper_start(&ch);
ms_connection_helper_unlink(&ch, stream->source, -1, 0);
if (stream->pixconv) {
ms_connection_helper_unlink(&ch, stream->pixconv, 0, 0);
}
if (stream->sizeconv) {
ms_connection_helper_unlink(&ch, stream->sizeconv, 0, 0);
}
ms_connection_helper_unlink(&ch, stream->tee, 0, 0);
ms_connection_helper_unlink(&ch, stream->encoder, 0, 0);
ms_connection_helper_unlink(&ch, stream->rtpsend, 0, -1);
if (stream->output2){
ms_filter_unlink(stream->tee,1,stream->output2,0);
}
}
if (stream->rtprecv){
if (stream->voidsink) {