-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67c1aba
commit 50a8a55
Showing
5 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...oid/source/premierlibrary/src/main/java/com/cicada/player/CicadaPlayerGlobalSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.cicada.player; | ||
|
||
|
||
public class CicadaPlayerGlobalSettings { | ||
|
||
static { | ||
System.loadLibrary("alivcffmpeg"); | ||
System.loadLibrary("CicadaPlayer"); | ||
} | ||
|
||
/** | ||
* 设置域名对应的解析ip | ||
* @param host 域名,需指定端口(http默认端口80,https默认端口443)。例如player.alicdn.com:80 | ||
* @param ip 相应的ip,设置为空字符串清空设定。 | ||
*/ | ||
/**** | ||
* Set a DNS ip to resolve the host. | ||
* @param host The host. Need to specify the port(http defualt port is 80,https default port is 443). E.g player.alicdn.com:80 | ||
* @param ip The ip address, set as empty string to clear the setting. | ||
*/ | ||
public static void setDNSResolve(String host, String ip){ | ||
nSetDNSResolve(host, ip); | ||
} | ||
|
||
private static native void nSetDNSResolve(String host, String ip); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
platform/Android/source/premierlibrary/src/main/jni/player/JavaGlobalSettings.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// Created by lifujun on 2020/4/9. | ||
// | ||
|
||
#include <utils/Android/FindClass.h> | ||
#include <utils/globalSettings.h> | ||
#include <utils/Android/GetStringUTFChars.h> | ||
#include "JavaGlobalSettings.h" | ||
|
||
static char *globalSettingsPath = (char *) ("com/cicada/player/CicadaPlayerGlobalSettings"); | ||
static jclass gj_GlobalSettings_Class = nullptr; | ||
|
||
void JavaGlobalSettings::init(JNIEnv *pEnv) | ||
{ | ||
if (gj_GlobalSettings_Class == nullptr) { | ||
FindClass cls(pEnv, globalSettingsPath); | ||
gj_GlobalSettings_Class = (jclass) pEnv->NewGlobalRef(cls.getClass()); | ||
} | ||
} | ||
|
||
void JavaGlobalSettings::unInit(JNIEnv *pEnv) | ||
{ | ||
if (gj_GlobalSettings_Class != nullptr) { | ||
pEnv->DeleteGlobalRef(gj_GlobalSettings_Class); | ||
gj_GlobalSettings_Class = nullptr; | ||
} | ||
} | ||
|
||
void JavaGlobalSettings::java_setDNSResolve(JNIEnv *mEnv, jclass clazz, jstring jhost, jstring jip) | ||
{ | ||
GetStringUTFChars hostStr(mEnv, jhost); | ||
char *hostChars = hostStr.getChars(); | ||
|
||
if (hostChars == nullptr || strlen(hostChars) == 0) { | ||
return; | ||
} | ||
|
||
Cicada::globalSettings::getSetting()->removeResolve(hostChars, ""); | ||
GetStringUTFChars ipStr(mEnv, jip); | ||
char *ipChars = ipStr.getChars(); | ||
|
||
if (ipChars != nullptr && strlen(ipChars) > 0) { | ||
Cicada::globalSettings::getSetting()->addResolve(hostChars, ipChars); | ||
} | ||
} | ||
|
||
|
||
static JNINativeMethod globalSettings_method_table[] = { | ||
{"nSetDNSResolve", "(Ljava/lang/String;Ljava/lang/String;)V", (void *) JavaGlobalSettings::java_setDNSResolve}, | ||
}; | ||
|
||
int JavaGlobalSettings::registerMethod(JNIEnv *pEnv) | ||
{ | ||
if (gj_GlobalSettings_Class == nullptr) { | ||
return JNI_FALSE; | ||
} | ||
|
||
if (pEnv->RegisterNatives(gj_GlobalSettings_Class, globalSettings_method_table, | ||
sizeof(globalSettings_method_table) / sizeof(JNINativeMethod)) < 0) { | ||
return JNI_FALSE; | ||
} | ||
|
||
return JNI_TRUE; | ||
} | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
platform/Android/source/premierlibrary/src/main/jni/player/JavaGlobalSettings.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// Created by lifujun on 2020/4/9. | ||
// | ||
|
||
#ifndef SOURCE_JAVAGLOBALSETTINGS_H | ||
#define SOURCE_JAVAGLOBALSETTINGS_H | ||
|
||
|
||
#include <jni.h> | ||
|
||
class JavaGlobalSettings { | ||
|
||
public: | ||
static void init(JNIEnv *pEnv); | ||
|
||
static void unInit(JNIEnv *pEnv); | ||
|
||
static int registerMethod(JNIEnv *pEnv); | ||
|
||
static void java_setDNSResolve(JNIEnv *mEnv, jclass clazz, jstring host, jstring ip); | ||
}; | ||
|
||
|
||
#endif //SOURCE_JAVAGLOBALSETTINGS_H |