Temporary fix to allow Invoke() calls for VP8 HW encoder and decoder.

BUG=
R=jiayl@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/24849004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7387 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc
index f482848..492c0ee 100644
--- a/talk/app/webrtc/java/jni/peerconnection_jni.cc
+++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc
@@ -1234,6 +1234,13 @@
   return TickTime::Now().Ticks() / 1000000LL;
 }
 
+// Allow Invoke() calls from from current thread.
+static void AllowBlockingCalls() {
+  Thread* current_thread = Thread::Current();
+  if (current_thread != NULL)
+    current_thread->SetAllowBlockingCalls(true);
+}
+
 // MediaCodecVideoEncoder is a webrtc::VideoEncoder implementation that uses
 // Android's MediaCodec SDK API behind the scenes to implement (hopefully)
 // HW-backed video encode.  This C++ class is implemented as a very thin shim,
@@ -1417,6 +1424,7 @@
   j_info_presentation_timestamp_us_field_ = GetFieldID(
       jni, j_output_buffer_info_class, "presentationTimestampUs", "J");
   CHECK_EXCEPTION(jni) << "MediaCodecVideoEncoder ctor failed";
+  AllowBlockingCalls();
 }
 
 int32_t MediaCodecVideoEncoder::InitEncode(
@@ -2142,6 +2150,7 @@
   if (render_egl_context_ == NULL)
     use_surface_ = false;
   memset(&codec_, 0, sizeof(codec_));
+  AllowBlockingCalls();
 }
 
 MediaCodecVideoDecoder::~MediaCodecVideoDecoder() {