OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 jni, *j_observer_class_, "onBufferedAmountChange", "(J)V")), | 595 jni, *j_observer_class_, "onBufferedAmountChange", "(J)V")), |
596 j_on_state_change_mid_( | 596 j_on_state_change_mid_( |
597 GetMethodID(jni, *j_observer_class_, "onStateChange", "()V")), | 597 GetMethodID(jni, *j_observer_class_, "onStateChange", "()V")), |
598 j_on_message_mid_(GetMethodID(jni, *j_observer_class_, "onMessage", | 598 j_on_message_mid_(GetMethodID(jni, *j_observer_class_, "onMessage", |
599 "(Lorg/webrtc/DataChannel$Buffer;)V")), | 599 "(Lorg/webrtc/DataChannel$Buffer;)V")), |
600 j_buffer_ctor_(GetMethodID(jni, *j_buffer_class_, "<init>", | 600 j_buffer_ctor_(GetMethodID(jni, *j_buffer_class_, "<init>", |
601 "(Ljava/nio/ByteBuffer;Z)V")) {} | 601 "(Ljava/nio/ByteBuffer;Z)V")) {} |
602 | 602 |
603 virtual ~DataChannelObserverWrapper() {} | 603 virtual ~DataChannelObserverWrapper() {} |
604 | 604 |
605 void OnBufferedAmountChange(uint64 previous_amount) override { | 605 void OnBufferedAmountChange(uint64_t previous_amount) override { |
606 ScopedLocalRefFrame local_ref_frame(jni()); | 606 ScopedLocalRefFrame local_ref_frame(jni()); |
607 jni()->CallVoidMethod(*j_observer_global_, j_on_buffered_amount_change_mid_, | 607 jni()->CallVoidMethod(*j_observer_global_, j_on_buffered_amount_change_mid_, |
608 previous_amount); | 608 previous_amount); |
609 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 609 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
610 } | 610 } |
611 | 611 |
612 void OnStateChange() override { | 612 void OnStateChange() override { |
613 ScopedLocalRefFrame local_ref_frame(jni()); | 613 ScopedLocalRefFrame local_ref_frame(jni()); |
614 jni()->CallVoidMethod(*j_observer_global_, j_on_state_change_mid_); | 614 jni()->CallVoidMethod(*j_observer_global_, j_on_state_change_mid_); |
615 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 615 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 private: | 789 private: |
790 // Return a VideoRenderer.I420Frame referring to the data in |frame|. | 790 // Return a VideoRenderer.I420Frame referring to the data in |frame|. |
791 jobject CricketToJavaI420Frame(const cricket::VideoFrame* frame) { | 791 jobject CricketToJavaI420Frame(const cricket::VideoFrame* frame) { |
792 jintArray strides = jni()->NewIntArray(3); | 792 jintArray strides = jni()->NewIntArray(3); |
793 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); | 793 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); |
794 strides_array[0] = frame->GetYPitch(); | 794 strides_array[0] = frame->GetYPitch(); |
795 strides_array[1] = frame->GetUPitch(); | 795 strides_array[1] = frame->GetUPitch(); |
796 strides_array[2] = frame->GetVPitch(); | 796 strides_array[2] = frame->GetVPitch(); |
797 jni()->ReleaseIntArrayElements(strides, strides_array, 0); | 797 jni()->ReleaseIntArrayElements(strides, strides_array, 0); |
798 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); | 798 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); |
799 jobject y_buffer = jni()->NewDirectByteBuffer( | 799 jobject y_buffer = |
800 const_cast<uint8*>(frame->GetYPlane()), | 800 jni()->NewDirectByteBuffer(const_cast<uint8_t*>(frame->GetYPlane()), |
801 frame->GetYPitch() * frame->GetHeight()); | 801 frame->GetYPitch() * frame->GetHeight()); |
802 jobject u_buffer = jni()->NewDirectByteBuffer( | 802 jobject u_buffer = jni()->NewDirectByteBuffer( |
803 const_cast<uint8*>(frame->GetUPlane()), frame->GetChromaSize()); | 803 const_cast<uint8_t*>(frame->GetUPlane()), frame->GetChromaSize()); |
804 jobject v_buffer = jni()->NewDirectByteBuffer( | 804 jobject v_buffer = jni()->NewDirectByteBuffer( |
805 const_cast<uint8*>(frame->GetVPlane()), frame->GetChromaSize()); | 805 const_cast<uint8_t*>(frame->GetVPlane()), frame->GetChromaSize()); |
806 jni()->SetObjectArrayElement(planes, 0, y_buffer); | 806 jni()->SetObjectArrayElement(planes, 0, y_buffer); |
807 jni()->SetObjectArrayElement(planes, 1, u_buffer); | 807 jni()->SetObjectArrayElement(planes, 1, u_buffer); |
808 jni()->SetObjectArrayElement(planes, 2, v_buffer); | 808 jni()->SetObjectArrayElement(planes, 2, v_buffer); |
809 return jni()->NewObject( | 809 return jni()->NewObject( |
810 *j_frame_class_, j_i420_frame_ctor_id_, | 810 *j_frame_class_, j_i420_frame_ctor_id_, |
811 frame->GetWidth(), frame->GetHeight(), | 811 frame->GetWidth(), frame->GetHeight(), |
812 static_cast<int>(frame->GetVideoRotation()), | 812 static_cast<int>(frame->GetVideoRotation()), |
813 strides, planes, frame); | 813 strides, planes, frame); |
814 } | 814 } |
815 | 815 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 JOW(jstring, DataChannel_label)(JNIEnv* jni, jobject j_dc) { | 863 JOW(jstring, DataChannel_label)(JNIEnv* jni, jobject j_dc) { |
864 return JavaStringFromStdString(jni, ExtractNativeDC(jni, j_dc)->label()); | 864 return JavaStringFromStdString(jni, ExtractNativeDC(jni, j_dc)->label()); |
865 } | 865 } |
866 | 866 |
867 JOW(jobject, DataChannel_state)(JNIEnv* jni, jobject j_dc) { | 867 JOW(jobject, DataChannel_state)(JNIEnv* jni, jobject j_dc) { |
868 return JavaEnumFromIndex( | 868 return JavaEnumFromIndex( |
869 jni, "DataChannel$State", ExtractNativeDC(jni, j_dc)->state()); | 869 jni, "DataChannel$State", ExtractNativeDC(jni, j_dc)->state()); |
870 } | 870 } |
871 | 871 |
872 JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) { | 872 JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) { |
873 uint64 buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount(); | 873 uint64_t buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount(); |
874 RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64>::max()) | 874 RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64_t>::max()) |
875 << "buffered_amount overflowed jlong!"; | 875 << "buffered_amount overflowed jlong!"; |
876 return static_cast<jlong>(buffered_amount); | 876 return static_cast<jlong>(buffered_amount); |
877 } | 877 } |
878 | 878 |
879 JOW(void, DataChannel_close)(JNIEnv* jni, jobject j_dc) { | 879 JOW(void, DataChannel_close)(JNIEnv* jni, jobject j_dc) { |
880 ExtractNativeDC(jni, j_dc)->Close(); | 880 ExtractNativeDC(jni, j_dc)->Close(); |
881 } | 881 } |
882 | 882 |
883 JOW(jboolean, DataChannel_sendNative)(JNIEnv* jni, jobject j_dc, | 883 JOW(jboolean, DataChannel_sendNative)(JNIEnv* jni, jobject j_dc, |
884 jbyteArray data, jboolean binary) { | 884 jbyteArray data, jboolean binary) { |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); | 1822 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); |
1823 stream->ReadAll(buffer.get(), log_size, &read, nullptr); | 1823 stream->ReadAll(buffer.get(), log_size, &read, nullptr); |
1824 | 1824 |
1825 jbyteArray result = jni->NewByteArray(read); | 1825 jbyteArray result = jni->NewByteArray(read); |
1826 jni->SetByteArrayRegion(result, 0, read, buffer.get()); | 1826 jni->SetByteArrayRegion(result, 0, read, buffer.get()); |
1827 | 1827 |
1828 return result; | 1828 return result; |
1829 } | 1829 } |
1830 | 1830 |
1831 } // namespace webrtc_jni | 1831 } // namespace webrtc_jni |
OLD | NEW |