Skip to content

Commit

Permalink
test prefab publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantin Geier committed Jul 5, 2020
1 parent 36f3d1d commit 74c9275
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 10 deletions.
15 changes: 15 additions & 0 deletions VideoCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ add_library( avformat-lib
add_library( avutil-lib
SHARED
IMPORTED )
add_library( swresample-lib
SHARED
IMPORTED )
set_target_properties( # Specifies the target library.
avcodec-lib
# Specifies the parameter you want to define.
Expand All @@ -34,6 +37,15 @@ set_target_properties( # Specifies the target library.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
${FFMPEG_DIR}/lib/${ANDROID_ABI}/libavutil.so)
# fix this ?
set_target_properties( # Specifies the target library.
swresample-lib
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
${FFMPEG_DIR}/lib/${ANDROID_ABI}/libswresample.so)


include_directories(${FFMPEG_DIR}/include/${ANDROID_ABI}/)

set(H264_BITSTREAM_DIR ${CMAKE_SOURCE_DIR}/libs/h264bitstream)
Expand Down Expand Up @@ -63,6 +75,9 @@ target_link_libraries( FFMpegVideoReceiver
avcodec-lib
avformat-lib
avutil-lib
#
swresample-lib

h264bitstream
)

Expand Down
14 changes: 12 additions & 2 deletions VideoCore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ android {
abiFilters 'armeabi-v7a', 'arm64-v8a'//, 'x86', 'x86_64'
}
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -34,7 +33,18 @@ android {
}
sourceSets {
main {
jniLibs.srcDirs = ['libs/ffmpeg/lib']
// https://developer.android.com/studio/releases/gradle-plugin?buildsystem=cmake#cmake-imported-targets
// Not needed anymore
//jniLibs.srcDirs = ['libs/ffmpeg/lib']
}
}
//
buildFeatures {
prefabPublishing true
}
prefab {
VideoNative {
headers "src/main/cpp/NALU"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions VideoCore/src/main/cpp/Decoder/LowLagDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ LowLagDecoder::LowLagDecoder(JavaVM* javaVm,ANativeWindow* window,bool SW):
SW(SW),javaVm(javaVm){
decoder.window=window;
decoder.configured=false;

}

void LowLagDecoder::registerOnDecoderRatioChangedCallback(DECODER_RATIO_CHANGED decoderRatioChangedC) {
Expand Down
6 changes: 6 additions & 0 deletions VideoCore/src/main/cpp/VideoPlayer/VideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@
#include <android/asset_manager_jni.h>
#include <FileHelper.hpp>

//TEST
//#include <NdkImage.h>
//#include <NdkImageReader.h>

VideoPlayer::VideoPlayer(JNIEnv* env, jobject context, const char* DIR) :
mParser{std::bind(&VideoPlayer::onNewNALU, this, std::placeholders::_1)},
mSettingsN(env,context,"pref_video",true),
GROUND_RECORDING_DIRECTORY(DIR),
mGroundRecorderFPV(GROUND_RECORDING_DIRECTORY),
mFileReceiver(1024){
env->GetJavaVM(&javaVm);

//AImageReader* imageReader = nullptr;
}

//Not yet parsed bit stream (e.g. raw h264 or rtp data)
Expand Down
2 changes: 1 addition & 1 deletion VideoExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

//firebase
implementation 'com.google.firebase:firebase-core:17.4.2'
implementation 'com.google.firebase:firebase-core:17.4.3'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
//implementation 'com.google.firebase:firebase-analytics:17.2.0'
//implementation 'com.google.firebase:firebase-perf:19.0.0'
Expand Down
4 changes: 2 additions & 2 deletions VideoTelemetryShared/InputOutput/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void FileReader::stopReadingIfStarted() {
started=false;
nReceivedB=0;
}

void FileReader::receiveLoop(std::future<void> shouldTerminate) {
nReceivedB=0;
if(FileHelper::endsWith(FILEPATH, ".mp4")) {
Expand All @@ -81,7 +81,7 @@ void FileReader::receiveLoop(std::future<void> shouldTerminate) {
auto elapsed=std::chrono::steady_clock::now()-start;
lastPacketTimestamp=packet.timestamp;
//wait until we are at least at the time when data was received
while(elapsed<packet.timestamp){//*0.5f
while(elapsed<packet.timestamp*0.4f){
elapsed=std::chrono::steady_clock::now()-start;
TestSleep::sleep(std::chrono::milliseconds(1));
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.1.0-beta02'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'io.fabric.tools:gradle:1.31.0'
Expand All @@ -28,7 +28,7 @@ allprojects {
jcenter()
}
ext {
minSdkVersion = 21
minSdkVersion = 29
compileSdkVersion = 29
targetSdkVersion = 29
appcompatVersion = '1.1.0'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 12 12:04:08 CEST 2020
#Fri Jul 03 14:15:32 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-rc-1-all.zip
2 changes: 1 addition & 1 deletion uvcintegration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation project(':VideoCore')
//implementation project(':VideoCore')

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package constantin.video.core;

import android.util.ArrayMap;

import java.util.Map;

@SuppressWarnings("WeakerAccess")
public class DecodingInfo {
public final float currentFPS;
public final float currentKiloBitsPerSecond;
public final float avgParsingTime_ms;
public final float avgWaitForInputBTime_ms;
public final float avgHWDecodingTime_ms; //time the hw decoder was holding on to frames. Not the full decoding time !
public final float avgTotalDecodingTime_ms;
public final int nNALU;
public final int nNALUSFeeded;

public DecodingInfo(){
currentFPS=0;
currentKiloBitsPerSecond=0;
avgParsingTime_ms=0;
avgWaitForInputBTime_ms=0;
avgHWDecodingTime_ms=0;
nNALU=0;
nNALUSFeeded=0;
avgTotalDecodingTime_ms =0;
}

public DecodingInfo(float currentFPS, float currentKiloBitsPerSecond,float avgParsingTime_ms,float avgWaitForInputBTime_ms,float avgHWDecodingTime_ms,
int nNALU,int nNALUSFeeded){
this.currentFPS=currentFPS;
this.currentKiloBitsPerSecond=currentKiloBitsPerSecond;
this.avgParsingTime_ms=avgParsingTime_ms;
this.avgWaitForInputBTime_ms=avgWaitForInputBTime_ms;
this.avgHWDecodingTime_ms =avgHWDecodingTime_ms;
this.avgTotalDecodingTime_ms =avgParsingTime_ms+avgWaitForInputBTime_ms+avgHWDecodingTime_ms;
this.nNALU=nNALU;
this.nNALUSFeeded=nNALUSFeeded;
}

public Map<String,Object> toMap(){
Map<String, Object> decodingInfo = new ArrayMap<>();
decodingInfo.put("currentFPS",currentFPS);
decodingInfo.put("currentKiloBitsPerSecond",currentKiloBitsPerSecond);
decodingInfo.put("avgParsingTime_ms",avgParsingTime_ms);
decodingInfo.put("avgWaitForInputBTime_ms",avgWaitForInputBTime_ms);
decodingInfo.put("avgHWDecodingTime_ms", avgHWDecodingTime_ms);
decodingInfo.put("avgTotalDecodingTime_ms", avgTotalDecodingTime_ms);
decodingInfo.put("nNALU",nNALU);
decodingInfo.put("nNALUSFeeded",nNALUSFeeded);
return decodingInfo;
}

public String toString(final boolean newline){
final StringBuilder builder=new StringBuilder();
builder.append( "Decoding info:\n");
final Map<String,Object> map=toMap();
for(final String key:map.keySet()){
//Either float or int, toString available
final Object value=map.get(key);
builder.append(key).append(":").append(value);
if(newline)builder.append("\n");
}
return builder.toString();
}

@Override
public String toString() {
return toString(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package constantin.video.core;


//Similar to INativeVideoParamsChanged,but instead of passing all float's it passes
//a DecodingInfo instance. Not called by native code
public interface IVideoParamsChanged{
void onVideoRatioChanged(int videoW, int videoH);
void onDecodingInfoChanged(final DecodingInfo decodingInfo);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package constantin.video.core.gl;

import android.graphics.SurfaceTexture;
import android.view.Surface;

public interface ISurfaceAvailable {
// Always called on the UI thread and while activity is in state == resumed
void XSurfaceCreated(final SurfaceTexture surfaceTexture, final Surface surface);
void XSurfaceDestroyed();
}

0 comments on commit 74c9275

Please sign in to comment.