PeerConnection(java): added MediaConstraints support to AudioSource, now fed to AudioTrack.
BUG=2912 R=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/8509004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5540 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
540acde5b3
commit
3eda643a91
@ -1971,12 +1971,25 @@ JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)(
|
||||
return (jlong)track.release();
|
||||
}
|
||||
|
||||
JOW(jlong, PeerConnectionFactory_nativeCreateAudioTrack)(
|
||||
JNIEnv* jni, jclass, jlong native_factory, jstring id) {
|
||||
JOW(jlong, PeerConnectionFactory_nativeCreateAudioSource)(
|
||||
JNIEnv* jni, jclass, jlong native_factory, jobject j_constraints) {
|
||||
scoped_ptr<ConstraintsWrapper> constraints(
|
||||
new ConstraintsWrapper(jni, j_constraints));
|
||||
talk_base::scoped_refptr<PeerConnectionFactoryInterface> factory(
|
||||
factoryFromJava(native_factory));
|
||||
talk_base::scoped_refptr<AudioTrackInterface> track(
|
||||
factory->CreateAudioTrack(JavaToStdString(jni, id), NULL));
|
||||
talk_base::scoped_refptr<AudioSourceInterface> source(
|
||||
factory->CreateAudioSource(constraints.get()));
|
||||
return (jlong)source.release();
|
||||
}
|
||||
|
||||
JOW(jlong, PeerConnectionFactory_nativeCreateAudioTrack)(
|
||||
JNIEnv* jni, jclass, jlong native_factory, jstring id,
|
||||
jlong native_source) {
|
||||
talk_base::scoped_refptr<PeerConnectionFactoryInterface> factory(
|
||||
factoryFromJava(native_factory));
|
||||
talk_base::scoped_refptr<AudioTrackInterface> track(factory->CreateAudioTrack(
|
||||
JavaToStdString(jni, id),
|
||||
reinterpret_cast<AudioSourceInterface*>(native_source)));
|
||||
return (jlong)track.release();
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,13 @@ public class PeerConnectionFactory {
|
||||
nativeFactory, id, source.nativeSource));
|
||||
}
|
||||
|
||||
public AudioTrack createAudioTrack(String id) {
|
||||
return new AudioTrack(nativeCreateAudioTrack(nativeFactory, id));
|
||||
public AudioSource createAudioSource(MediaConstraints constraints) {
|
||||
return new AudioSource(nativeCreateAudioSource(nativeFactory, constraints));
|
||||
}
|
||||
|
||||
public AudioTrack createAudioTrack(String id, AudioSource source) {
|
||||
return new AudioTrack(nativeCreateAudioTrack(
|
||||
nativeFactory, id, source.nativeSource));
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@ -112,8 +117,11 @@ public class PeerConnectionFactory {
|
||||
private static native long nativeCreateVideoTrack(
|
||||
long nativeFactory, String id, long nativeVideoSource);
|
||||
|
||||
private static native long nativeCreateAudioSource(
|
||||
long nativeFactory, MediaConstraints constraints);
|
||||
|
||||
private static native long nativeCreateAudioTrack(
|
||||
long nativeFactory, String id);
|
||||
long nativeFactory, String id, long nativeSource);
|
||||
|
||||
private static native void freeFactory(long nativeFactory);
|
||||
}
|
||||
|
@ -481,7 +481,8 @@ public class PeerConnectionTest extends TestCase {
|
||||
// Just for fun, let's remove and re-add the track.
|
||||
lMS.removeTrack(videoTrack);
|
||||
lMS.addTrack(videoTrack);
|
||||
lMS.addTrack(factory.createAudioTrack(audioTrackId));
|
||||
lMS.addTrack(factory.createAudioTrack(
|
||||
audioTrackId, factory.createAudioSource(new MediaConstraints())));
|
||||
pc.addStream(lMS, new MediaConstraints());
|
||||
return new WeakReference<MediaStream>(lMS);
|
||||
}
|
||||
|
@ -242,7 +242,9 @@ public class AppRTCDemoActivity extends Activity
|
||||
lMS.addTrack(videoTrack);
|
||||
}
|
||||
if (appRtcClient.audioConstraints() != null) {
|
||||
lMS.addTrack(factory.createAudioTrack("ARDAMSa0"));
|
||||
lMS.addTrack(factory.createAudioTrack(
|
||||
"ARDAMSa0",
|
||||
factory.createAudioSource(appRtcClient.audioConstraints())));
|
||||
}
|
||||
pc.addStream(lMS, new MediaConstraints());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user