summaryrefslogtreecommitdiff
authorTellen Yu <tellen.yu@amlogic.com>2017-04-06 02:08:24 (GMT)
committer Gerrit Code Review <gituser@git.myamlogic.com>2017-04-06 02:08:24 (GMT)
commite1c60e2c4f88230e787655e71b925cfe83b470d5 (patch)
treeffe883873b624dcab7f6915d57f307d9f021e555
parentff5be508c0627e644dce7ff2e0f107fc8c5d5115 (diff)
parentcc975495e1039978ba823c9ee2e09532364f877e (diff)
downloadSubTitle-e1c60e2c4f88230e787655e71b925cfe83b470d5.zip
SubTitle-e1c60e2c4f88230e787655e71b925cfe83b470d5.tar.gz
SubTitle-e1c60e2c4f88230e787655e71b925cfe83b470d5.tar.bz2
Merge "PD #142010: get pcr from socket while playing by nuplayer" into m-amlogic
Diffstat
-rw-r--r--jni/subtitle/sub_io.cpp4
-rw-r--r--jni/subtitle/sub_io.h1
-rw-r--r--jni/subtitle/sub_jni.c11
-rw-r--r--jni/subtitle/sub_socket.cpp20
-rw-r--r--jni/subtitle/sub_socket.h2
-rw-r--r--src/com/droidlogic/SubTitleService/ISubTitleService.aidl1
-rw-r--r--src/com/droidlogic/SubTitleService/SubTitleService.java4
-rw-r--r--src/com/subtitleparser/Subtitle.java5
-rw-r--r--src/com/subtitleview/SubManager.java8
-rw-r--r--src/com/subtitleview/SubtitleView.java4
10 files changed, 59 insertions, 1 deletions
diff --git a/jni/subtitle/sub_io.cpp b/jni/subtitle/sub_io.cpp
index bc6bac1..4f2eac1 100644
--- a/jni/subtitle/sub_io.cpp
+++ b/jni/subtitle/sub_io.cpp
@@ -84,3 +84,7 @@ void setIOType(IOType type) {
IOType getIOType() {
return mIOType;
}
+
+void getPcrscr(char* pcrStr) {
+ getPcrscrBySkt(pcrStr);
+}
diff --git a/jni/subtitle/sub_io.h b/jni/subtitle/sub_io.h
index 24ae813..943c7d0 100644
--- a/jni/subtitle/sub_io.h
+++ b/jni/subtitle/sub_io.h
@@ -30,6 +30,7 @@ int getSize(int sub_fd);
void getData(int sub_fd, char *buf, int size);
void setIOType(IOType type);
IOType getIOType();
+void getPcrscr(char* pcrStr);
#ifdef __cplusplus
}
diff --git a/jni/subtitle/sub_jni.c b/jni/subtitle/sub_jni.c
index 03b313f..5022ef5 100644
--- a/jni/subtitle/sub_jni.c
+++ b/jni/subtitle/sub_jni.c
@@ -663,6 +663,16 @@ JNIEXPORT void JNICALL setSubIOType(JNIEnv *env, jclass cl, jint type)
setIOType(type);
}
+JNIEXPORT jstring JNICALL getSubPcrscr(JNIEnv *env, jclass cl)
+{
+ LOGI("getPcrscr");
+ jstring jstr;
+ char pcrStr[1024] = { 0 };
+ getPcrscr(pcrStr);
+ jstr = string2jstring(env, pcrStr);
+ return jstr;
+}
+
JNIEXPORT void JNICALL stopSubThread(JNIEnv *env, jclass cl)
{
if (subThreadRunning == 1)
@@ -691,6 +701,7 @@ static JNINativeMethod gMethods[] =
{ "startSubServerByJni", "()V",(void*) startSubServer},
{ "stopSubServerByJni", "()V",(void*) stopSubServer},
{ "setIOTypeByJni", "(I)V",(void*) setSubIOType},
+ { "getPcrscrByJni", "()Ljava/lang/String;",(void*) getSubPcrscr},
};
static JNINativeMethod insubMethods[] =
diff --git a/jni/subtitle/sub_socket.cpp b/jni/subtitle/sub_socket.cpp
index 6a4d0ad..75e85de 100644
--- a/jni/subtitle/sub_socket.cpp
+++ b/jni/subtitle/sub_socket.cpp
@@ -36,6 +36,7 @@
#include <errno.h>
#include <sys/stat.h>
#include<pthread.h>
+#include <inttypes.h>
#include "sub_socket.h"
@@ -217,7 +218,7 @@ void child_connect(int sockfd) {
| (recvBuf[5] << 16)
| (recvBuf[6] << 8)
| recvBuf[7];
- ALOGI("child recv, mStartPts:%d\n", mStartPts);
+ ALOGI("child recv, mStartPts:%" PRId64 "\n", mStartPts);
}
else if (recvBuf[0] == 0x53
&& recvBuf[1] == 0x54
@@ -230,6 +231,16 @@ void child_connect(int sockfd) {
| recvBuf[7];
ALOGI("child recv, mType:%d\n", mType);
}
+ else if (recvBuf[0] == 0x53
+ && recvBuf[1] == 0x52
+ && recvBuf[2] == 0x44
+ && recvBuf[3] == 0x54) {//SRDT //subtitle render time
+ mTimeUs = (recvBuf[4] << 24)
+ | (recvBuf[5] << 16)
+ | (recvBuf[6] << 8)
+ | recvBuf[7];
+ ALOGI("child recv, mTimeUs:%d\n", mTimeUs);
+ }
else/* if (recvBuf[0] == 'A' && recvBuf[1] == 'M' && recvBuf[2] == 'L') */{
safeCopy(mLoopBuf, recvBuf, retLen);
}
@@ -301,3 +312,10 @@ int getInfoBySkt(int type) {
//ALOGI("[getInfo]type:%d, ret:%d\n", type, ret);
return ret;
}
+
+void getPcrscrBySkt(char* pcrStr) {
+ int64_t pcr = mTimeUs/1000*90 + mStartPts;
+ sprintf(pcrStr, "0x%x", pcr);
+
+ //ALOGI("[getPcrscr]pcr:%x, pcrStr:%s\n",pcr, pcrStr);
+}
diff --git a/jni/subtitle/sub_socket.h b/jni/subtitle/sub_socket.h
index 0f1ac74..276eb4c 100644
--- a/jni/subtitle/sub_socket.h
+++ b/jni/subtitle/sub_socket.h
@@ -23,6 +23,7 @@ static char *mRPtr;
static char *mWPtr;
static int mTotal;
static int mType;
+static int64_t mTimeUs;
static int64_t mStartPts;
static int64_t mSize;
@@ -42,6 +43,7 @@ int getSizeBySkt();
void getDataBySkt(char *buf, int size);
int getInfoBySkt(int type);
void resetSocketBuffer();
+void getPcrscrBySkt(char* pcrStr);
#ifdef __cplusplus
}
diff --git a/src/com/droidlogic/SubTitleService/ISubTitleService.aidl b/src/com/droidlogic/SubTitleService/ISubTitleService.aidl
index bfbede9..1fda1fa 100644
--- a/src/com/droidlogic/SubTitleService/ISubTitleService.aidl
+++ b/src/com/droidlogic/SubTitleService/ISubTitleService.aidl
@@ -33,4 +33,5 @@ interface ISubTitleService
boolean load(String path);
void setSurfaceViewParam(int x, int y, int w, int h);
void setIOType(int type);
+ String getPcrscr();
} \ No newline at end of file
diff --git a/src/com/droidlogic/SubTitleService/SubTitleService.java b/src/com/droidlogic/SubTitleService/SubTitleService.java
index 505268f..0518cc6 100644
--- a/src/com/droidlogic/SubTitleService/SubTitleService.java
+++ b/src/com/droidlogic/SubTitleService/SubTitleService.java
@@ -326,6 +326,10 @@ public class SubTitleService extends ISubTitleService.Stub {
sendSetIOTypeMsg(type);
}
+ public String getPcrscr() {
+ return subTitleView.getPcrscr();
+ }
+
public void option() {
sendOptionMsg();
}
diff --git a/src/com/subtitleparser/Subtitle.java b/src/com/subtitleparser/Subtitle.java
index 4ffec79..9bd9f42 100644
--- a/src/com/subtitleparser/Subtitle.java
+++ b/src/com/subtitleparser/Subtitle.java
@@ -158,6 +158,10 @@ public class Subtitle {
setIOTypeByJni(type);
}
+ public String getPcrscr() {
+ return getPcrscrByJni();
+ }
+
public void resetForSeek() {
resetForSeekByjni();
}
@@ -169,6 +173,7 @@ public class Subtitle {
native void startSubServerByJni();
native void stopSubServerByJni();
native void setIOTypeByJni(int type);
+ native String getPcrscrByJni();
/**
* Parse a known type subtitle file into a SubtitleFile object.
diff --git a/src/com/subtitleview/SubManager.java b/src/com/subtitleview/SubManager.java
index ea0b6fa..53e6a4a 100644
--- a/src/com/subtitleview/SubManager.java
+++ b/src/com/subtitleview/SubManager.java
@@ -65,6 +65,14 @@ public class SubManager {
}
}
+ public String getPcrscr() {
+ String ret = null;
+ if (subtitle != null) {
+ ret = subtitle.getPcrscr();
+ }
+ return ret;
+ }
+
public void loadSubtitleFile (String path, String enc) throws Exception {
if (subapi != null) {
if (subapi.type() == Subtitle.SUBTYPE.INSUB) {
diff --git a/src/com/subtitleview/SubtitleView.java b/src/com/subtitleview/SubtitleView.java
index beafa11..65d7cb9 100644
--- a/src/com/subtitleview/SubtitleView.java
+++ b/src/com/subtitleview/SubtitleView.java
@@ -577,6 +577,10 @@ public class SubtitleView extends FrameLayout {
SubManager.getinstance().setIOType(type);
}
+ public String getPcrscr() {
+ return SubManager.getinstance().getPcrscr();
+ }
+
public void loadSubtitleFile (String path, String enc) throws Exception {
SubManager.getinstance().loadSubtitleFile (path, enc);
}