Android: Remove VideoRenderer.Callbacks.canApplyRotation()

The only real implementation of VideoRenderer.Callbacks, VideoRendererGui, can always apply rotation. We don't need this in the interface.

BUG=webrtc:4145
R=glaznev@webrtc.org, guoweis@webrtc.org

Review URL: https://codereview.webrtc.org/1306073003 .

Cr-Commit-Position: refs/heads/master@{#9772}
This commit is contained in:
Magnus Jedvert 2015-08-25 09:32:06 +02:00
parent bc2296de9e
commit 7ef9d9104d
6 changed files with 11 additions and 90 deletions

View File

@ -50,12 +50,6 @@ public class VideoCapturerAndroidTest extends ActivityTestCase {
}
}
// TODO(guoweis): Remove this once chrome code base is updated.
@Override
public boolean canApplyRotation() {
return false;
}
public int WaitForNextFrameToRender() throws InterruptedException {
synchronized (frameLock) {
frameLock.wait();

View File

@ -454,12 +454,6 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
// Request rendering.
surface.requestRender();
}
// TODO(guoweis): Remove this once chrome code base is updated.
@Override
public boolean canApplyRotation() {
return true;
}
}
/** Passes GLSurfaceView to video renderer. */

View File

@ -740,9 +740,6 @@ class JavaVideoRendererWrapper : public VideoRendererInterface {
j_render_frame_id_(GetMethodID(
jni, GetObjectClass(jni, j_callbacks), "renderFrame",
"(Lorg/webrtc/VideoRenderer$I420Frame;)V")),
j_can_apply_rotation_id_(GetMethodID(
jni, GetObjectClass(jni, j_callbacks),
"canApplyRotation", "()Z")),
j_frame_class_(jni,
FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")),
j_i420_frame_ctor_id_(GetMethodID(
@ -750,9 +747,7 @@ class JavaVideoRendererWrapper : public VideoRendererInterface {
j_texture_frame_ctor_id_(GetMethodID(
jni, *j_frame_class_, "<init>",
"(IIILjava/lang/Object;I)V")),
j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")),
can_apply_rotation_set_(false),
can_apply_rotation_(false) {
j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) {
CHECK_EXCEPTION(jni);
}
@ -760,38 +755,16 @@ class JavaVideoRendererWrapper : public VideoRendererInterface {
void RenderFrame(const cricket::VideoFrame* video_frame) override {
ScopedLocalRefFrame local_ref_frame(jni());
// Calling CanApplyRotation here to ensure can_apply_rotation_ is set.
CanApplyRotation();
const cricket::VideoFrame* frame =
can_apply_rotation_ ? video_frame
: video_frame->GetCopyWithRotationApplied();
if (frame->GetNativeHandle() != NULL) {
jobject j_frame = CricketToJavaTextureFrame(frame);
jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame);
CHECK_EXCEPTION(jni());
} else {
jobject j_frame = CricketToJavaI420Frame(frame);
jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame);
CHECK_EXCEPTION(jni());
}
jobject j_frame = (video_frame->GetNativeHandle() != nullptr)
? CricketToJavaTextureFrame(video_frame)
: CricketToJavaI420Frame(video_frame);
jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame);
CHECK_EXCEPTION(jni());
}
// TODO(guoweis): Report that rotation is supported as RenderFrame calls
// GetCopyWithRotationApplied.
virtual bool CanApplyRotation() override {
if (can_apply_rotation_set_) {
return can_apply_rotation_;
}
ScopedLocalRefFrame local_ref_frame(jni());
jboolean ret =
jni()->CallBooleanMethod(*j_callbacks_, j_can_apply_rotation_id_);
CHECK_EXCEPTION(jni());
can_apply_rotation_ = ret;
can_apply_rotation_set_ = true;
return ret;
}
virtual bool CanApplyRotation() override { return true; }
private:
// Return a VideoRenderer.I420Frame referring to the data in |frame|.
@ -839,13 +812,10 @@ class JavaVideoRendererWrapper : public VideoRendererInterface {
ScopedGlobalRef<jobject> j_callbacks_;
jmethodID j_render_frame_id_;
jmethodID j_can_apply_rotation_id_;
ScopedGlobalRef<jclass> j_frame_class_;
jmethodID j_i420_frame_ctor_id_;
jmethodID j_texture_frame_ctor_id_;
ScopedGlobalRef<jclass> j_byte_buffer_class_;
bool can_apply_rotation_set_;
bool can_apply_rotation_;
};

View File

@ -172,8 +172,6 @@ public class VideoRenderer {
// |frame| might have pending rotation and implementation of Callbacks
// should handle that by applying rotation during rendering.
public void renderFrame(I420Frame frame);
// TODO(guoweis): Remove this once chrome code base is updated.
public boolean canApplyRotation();
}
// |this| either wraps a native (GUI) renderer or a client-supplied Callbacks

View File

@ -134,16 +134,10 @@ public class PeerConnectionTest {
@Override
public synchronized void renderFrame(VideoRenderer.I420Frame frame) {
setSize(frame.width, frame.height);
setSize(frame.rotatedWidth(), frame.rotatedHeight());
--expectedFramesDelivered;
}
// TODO(guoweis): Remove this once chrome code base is updated.
@Override
public boolean canApplyRotation() {
return false;
}
public synchronized void expectSignalingChange(SignalingState newState) {
expectedSignalingChanges.add(newState);
}
@ -438,30 +432,6 @@ public class PeerConnectionTest {
static int videoWindowsMapped = -1;
private static class TestRenderer implements VideoRenderer.Callbacks {
public int width = -1;
public int height = -1;
public int numFramesDelivered = 0;
private void setSize(int width, int height) {
assertEquals(this.width, -1);
assertEquals(this.height, -1);
this.width = width;
this.height = height;
}
@Override
public void renderFrame(VideoRenderer.I420Frame frame) {
++numFramesDelivered;
}
// TODO(guoweis): Remove this once chrome code base is updated.
@Override
public boolean canApplyRotation() {
return false;
}
}
private static VideoRenderer createVideoRenderer(
VideoRenderer.Callbacks videoCallbacks) {
if (!RENDER_TO_GUI) {

View File

@ -83,19 +83,14 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
doneRendering = new CountDownLatch(expectedFrames);
}
// TODO(guoweis): Remove this once chrome code base is updated.
@Override
public boolean canApplyRotation() {
return false;
}
@Override
public synchronized void renderFrame(VideoRenderer.I420Frame frame) {
if (!renderFrameCalled) {
if (rendererName != null) {
Log.d(TAG, rendererName + " render frame: " + frame.width + " x " + frame.height);
Log.d(TAG, rendererName + " render frame: "
+ frame.rotatedWidth() + " x " + frame.rotatedHeight());
} else {
Log.d(TAG, "Render frame: " + frame.width + " x " + frame.height);
Log.d(TAG, "Render frame: " + frame.rotatedWidth() + " x " + frame.rotatedHeight());
}
}
renderFrameCalled = true;