Skip to content

Commit

Permalink
tag2.1, fix一些崩溃bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rexbu committed Mar 31, 2017
1 parent be4949e commit 8d3738e
Show file tree
Hide file tree
Showing 80 changed files with 939 additions and 706 deletions.
Binary file added android/android.apk
Binary file not shown.
Binary file modified android/libs/arm64-v8a/libvisionin.so
Binary file not shown.
Binary file modified android/libs/armeabi-v7a/libvisionin.so
Binary file not shown.
6 changes: 4 additions & 2 deletions android/src/com/visionin/core/VSProps.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public class VSProps {
static {
long so = NativeLoad.loadSo("libvisionin.so");
NativeLoad.registJNIMethod(so, "com/visionin/core/VSProps", "startProps", "(Ljava/lang/String;Z)Z");
NativeLoad.registJNIMethod(so, "com/visionin/core/VSProps", "setTextureProps", "(Ljava/lang/String;IIZ)Z");
NativeLoad.registJNIMethod(so, "com/visionin/core/VSProps", "setTextureProps", "(Ljava/lang/String;)Z");
NativeLoad.registJNIMethod(so, "com/visionin/core/VSProps", "renderTextureProps", "(IIZ)Z");
NativeLoad.registJNIMethod(so, "com/visionin/core/VSProps", "stopProps", "()V");
NativeLoad.registJNIMethod(so, "com/visionin/core/VSProps", "destroyProps", "()V");
}

public static native boolean startProps(String propsZipPath, boolean mirror);
public static native boolean setTextureProps(String jpath, int in_texture, int out_texture, boolean mirror);
public static native boolean setTextureProps(String jpath);
public static native boolean renderTextureProps(int in_texture, int out_texture, boolean mirror);
public static native void stopProps();
public static native void destroyProps();
}
317 changes: 180 additions & 137 deletions demo/android/.idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified demo/android/libs/arm64-v8a/libvisionin.so
Binary file not shown.
Binary file modified demo/android/libs/armeabi-v7a/libvisionin.so
Binary file not shown.
2 changes: 1 addition & 1 deletion demo/android/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<Button
android:id="@+id/bytesButton"
android:text="处理Bytes的Demo(速度较慢)"
android:text="处理Bytes的Demo(暂不可用)"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
Expand Down
11 changes: 5 additions & 6 deletions demo/android/src/com/visionin/demo/TextureActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ protected void onResume() {

@Override
protected void onPause() {
if (videoFrame!=null){
videoFrame.stop();
}
com.rex.utils.CameraUtil.releaseCamera();
super.onPause();
}

Expand Down Expand Up @@ -150,10 +146,13 @@ public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {

@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
videoFrame.stop();
VSProps.stopProps();
if (videoFrame!=null){
videoFrame.stop();
}
VSProps.destroyProps();
VSFacer.destroyFacer();
videoFrame.destroy();
com.rex.utils.CameraUtil.releaseCamera();
videoFrame = null;
}

Expand Down
Binary file modified demo/ios/.DS_Store
Binary file not shown.
46 changes: 19 additions & 27 deletions demo/ios/VisioninDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
C8ED533A1E5C328E00796B4E /* VSVideoCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = C8ED53391E5C328E00796B4E /* VSVideoCamera.m */; };
C8ED533F1E5C32B000796B4E /* facer.model in Resources */ = {isa = PBXBuildFile; fileRef = C8ED533D1E5C32B000796B4E /* facer.model */; };
C8ED53401E5C32B000796B4E /* visionin.res in Resources */ = {isa = PBXBuildFile; fileRef = C8ED533E1E5C32B000796B4E /* visionin.res */; };
C8F192181E8EAED300A6D552 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C8F192161E8EAED300A6D552 /* HomeViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -80,14 +81,12 @@
C8ED53251E5C322500796B4E /* libz.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.dylib; path = ../../../../../../../usr/lib/libz.1.dylib; sourceTree = "<group>"; };
C8ED53271E5C323300796B4E /* libc++.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libc++.1.dylib"; path = "../../../../../../../usr/lib/libc++.1.dylib"; sourceTree = "<group>"; };
C8ED53291E5C324700796B4E /* libstdc++.6.0.9.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libstdc++.6.0.9.dylib"; path = "../../../../../../../usr/lib/libstdc++.6.0.9.dylib"; sourceTree = "<group>"; };
C8ED53341E5C327E00796B4E /* VSFacer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSFacer.h; path = VisioninSDK/include/VSFacer.h; sourceTree = "<group>"; };
C8ED53351E5C327E00796B4E /* VSProps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSProps.h; path = VisioninSDK/include/VSProps.h; sourceTree = "<group>"; };
C8ED53361E5C327E00796B4E /* Visionin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Visionin.h; path = VisioninSDK/include/Visionin.h; sourceTree = "<group>"; };
C8ED53371E5C327E00796B4E /* VSVideoFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSVideoFrame.h; path = VisioninSDK/include/VSVideoFrame.h; sourceTree = "<group>"; };
C8ED53381E5C327E00796B4E /* VSVideoCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSVideoCamera.h; path = VisioninSDK/include/VSVideoCamera.h; sourceTree = "<group>"; };
C8ED53391E5C328E00796B4E /* VSVideoCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VSVideoCamera.m; path = VisioninSDK/VSVideoCamera.m; sourceTree = "<group>"; };
C8ED533D1E5C32B000796B4E /* facer.model */ = {isa = PBXFileReference; lastKnownFileType = file; name = facer.model; path = VisioninSDK/facer.model; sourceTree = "<group>"; };
C8ED533E1E5C32B000796B4E /* visionin.res */ = {isa = PBXFileReference; lastKnownFileType = file; name = visionin.res; path = VisioninSDK/visionin.res; sourceTree = "<group>"; };
C8F192161E8EAED300A6D552 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
C8F192171E8EAED300A6D552 /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = "<group>"; };
C8F192191E8EAF5B00A6D552 /* VSVideoCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VSVideoCamera.h; path = VisioninSDK/VSVideoCamera.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -138,20 +137,22 @@
C8ED52D01E5C30BA00796B4E /* VisioninDemo */ = {
isa = PBXGroup;
children = (
C84B840D1E6EC7A000FAE377 /* cat.zip */,
C8ED533D1E5C32B000796B4E /* facer.model */,
C8ED533E1E5C32B000796B4E /* visionin.res */,
C8ED52D41E5C30BA00796B4E /* AppDelegate.h */,
C8ED52D71E5C30BA00796B4E /* ViewController.h */,
C8ED52D51E5C30BA00796B4E /* AppDelegate.m */,
C8ED52D81E5C30BA00796B4E /* ViewController.m */,
C8ED53391E5C328E00796B4E /* VSVideoCamera.m */,
C8ED52E21E5C30BA00796B4E /* Info.plist */,
C8ED52DD1E5C30BA00796B4E /* Assets.xcassets */,
C84B840D1E6EC7A000FAE377 /* cat.zip */,
C8ED533D1E5C32B000796B4E /* facer.model */,
C8F192171E8EAED300A6D552 /* HomeViewController.h */,
C8F192161E8EAED300A6D552 /* HomeViewController.m */,
C8ED52E21E5C30BA00796B4E /* Info.plist */,
C8ED52DF1E5C30BA00796B4E /* LaunchScreen.storyboard */,
C8ED52DA1E5C30BA00796B4E /* Main.storyboard */,
C8ED52D11E5C30BA00796B4E /* Supporting Files */,
C8ED53331E5C326500796B4E /* VisioninSDK */,
C8ED52D71E5C30BA00796B4E /* ViewController.h */,
C8ED52D81E5C30BA00796B4E /* ViewController.m */,
C8ED533E1E5C32B000796B4E /* visionin.res */,
C8F192191E8EAF5B00A6D552 /* VSVideoCamera.h */,
C8ED53391E5C328E00796B4E /* VSVideoCamera.m */,
);
path = VisioninDemo;
sourceTree = "<group>";
Expand Down Expand Up @@ -186,18 +187,6 @@
name = Frameworks;
sourceTree = "<group>";
};
C8ED53331E5C326500796B4E /* VisioninSDK */ = {
isa = PBXGroup;
children = (
C8ED53341E5C327E00796B4E /* VSFacer.h */,
C8ED53351E5C327E00796B4E /* VSProps.h */,
C8ED53361E5C327E00796B4E /* Visionin.h */,
C8ED53371E5C327E00796B4E /* VSVideoFrame.h */,
C8ED53381E5C327E00796B4E /* VSVideoCamera.h */,
);
name = VisioninSDK;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -277,6 +266,7 @@
C8ED52D91E5C30BA00796B4E /* ViewController.m in Sources */,
C8ED52D61E5C30BA00796B4E /* AppDelegate.m in Sources */,
C8ED52D31E5C30BA00796B4E /* main.m in Sources */,
C8F192181E8EAED300A6D552 /* HomeViewController.m in Sources */,
C8ED533A1E5C328E00796B4E /* VSVideoCamera.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -405,11 +395,12 @@
"$(inherited)",
"$(PROJECT_DIR)/VisioninDemo/VisioninSDK",
);
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/VisioninDemo/VisioninSDK/Visionin.framework/Headers";
INFOPLIST_FILE = VisioninDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/VisioninDemo/VisioninSDK",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = com.visionin.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -426,11 +417,12 @@
"$(inherited)",
"$(PROJECT_DIR)/VisioninDemo/VisioninSDK",
);
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/VisioninDemo/VisioninSDK/Visionin.framework/Headers";
INFOPLIST_FILE = VisioninDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/VisioninDemo/VisioninSDK",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = com.visionin.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions demo/ios/VisioninDemo/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "AppDelegate.h"
#import "HomeViewController.h"

@interface AppDelegate ()

Expand All @@ -17,6 +18,14 @@ @implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];

//((__bridge UIView*)f->rootUIView()).backgroundColor = [UIColor orangeColor];
self.window.rootViewController = [[HomeViewController alloc] init];

[self.window makeKeyAndVisible];

return YES;
}

Expand Down
14 changes: 14 additions & 0 deletions demo/ios/VisioninDemo/HomeViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// HomeViewController.h
// VisioninDemo
//
// Created by Visionin on 17/3/31.
// Copyright © 2017年 Rex. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface HomeViewController : UIViewController

@end
36 changes: 36 additions & 0 deletions demo/ios/VisioninDemo/HomeViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// HomeViewController.m
// VisioninDemo
//
// Created by Visionin on 17/3/31.
// Copyright © 2017年 Rex. All rights reserved.
//

#import "HomeViewController.h"
#import "ViewController.h"

@implementation HomeViewController

-(id) init{
self = [super init];


return self;
}

- (void)viewDidLoad {
[super viewDidLoad];

CGSize size = self.view.bounds.size;
UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(size.width/2-60, size.height/2-30, 120, 60)];
[button setTitle:@"点击进入" forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor blueColor]];
[button addTarget:self action:@selector(enter) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:button];
}

-(void)enter{
ViewController* view = [[ViewController alloc] init];
[self presentViewController:view animated:YES completion:nil];
}
@end
24 changes: 15 additions & 9 deletions demo/ios/VisioninDemo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#import "VSProps.h"
#import "VSFacer.h"

static bool initViewFlag = true;

@interface ViewController (){
VSVideoCamera* videoCamera;
UITextView* smoothView;
Expand Down Expand Up @@ -67,7 +69,7 @@ -(void)initVideoFrame{

// 加载贴纸
NSString* props = [[NSBundle mainBundle] pathForResource:@"cat" ofType:@"zip"];
//[[VSProps shareInstance] startLocalProps:props];
[[VSProps shareInstance] startLocalProps:props];

// __block typeof(self) parent = self;
// [videoCamera setBgraPixelBlock:^(CVPixelBufferRef pixelBuffer, CMTime time) {
Expand Down Expand Up @@ -103,9 +105,10 @@ - (void)initView{
// [self.view addSubview:videoView];

UIButton* record = [[UIButton alloc]initWithFrame:CGRectMake(10, 20, 60, 40)];
[record setTitle:@"开始" forState:UIControlStateNormal];
[record setTitle:@"返回" forState:UIControlStateNormal];
[record setBackgroundColor:[UIColor orangeColor]];
[record addTarget:self action:@selector(startVideo) forControlEvents:UIControlEventTouchUpInside];
[record addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];

UIButton* stop = [[UIButton alloc]initWithFrame:CGRectMake(80, 20, 60, 40)];
[stop setTitle:@"停止" forState:UIControlStateNormal];
[stop setBackgroundColor:[UIColor orangeColor]];
Expand Down Expand Up @@ -184,9 +187,13 @@ - (void)initView{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}

-(void)startVideo{
[self initVideoFrame];
[videoCamera startCameraCapture];
-(void)back{
[videoCamera stopCameraCapture];
[VSProps destroyInstance];
[VSFacer destroyInstance];
videoCamera = nil;
initViewFlag = true;
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)stopVideo{
Expand All @@ -196,10 +203,9 @@ -(void)stopVideo{

- (void)viewDidLayoutSubviews {
//self.view setBounds:CGRectMake(0, 0, self.view, CGFloat height)
static bool flag = true;
if (flag) {
if (initViewFlag) {
[self initView];
flag = false;
initViewFlag = false;
}
}

Expand Down
Binary file modified demo/ios/VisioninDemo/VisioninSDK/.DS_Store
Binary file not shown.
Binary file modified demo/ios/VisioninDemo/VisioninSDK/MoCross.framework/.DS_Store
Binary file not shown.
Binary file modified demo/ios/VisioninDemo/VisioninSDK/MoCross.framework/MoCross
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@

class AsyncFrame: public LoopThread{
public:
AsyncFrame(uint32_t time=0);
AsyncFrame(uint32_t time=0, bool ispipe=true);
~AsyncFrame(){}
// Override
void stop();
void loop();
// 让select立刻返回
void interrupt();

const static int FRAME_STATE_IDLE = 0;
const static int FRAME_STATE_LISTEN = 1;
const static int FRAME_STATE_HANDLE = 2;

protected:
// select立刻返回后的处理函数
virtual void interruptHandle(){};
Expand All @@ -32,7 +36,9 @@ class AsyncFrame: public LoopThread{
int m_max_sock;
// 0代表超时或者select interrupt,无socket准备就绪
int m_select_rv;
int m_frame_state;

bool m_ispipe;
fd_set m_read_set;
fd_set m_write_set;
fd_set m_error_set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@
#include <jni.h>
#endif

typedef struct sock_message_t{
typedef struct sock_msg_t{
object_t base;
int sock;
uint32_t size;
char buf[SOCKET_UDP_MTU];
int size;
char* buf;
struct sockaddr_in addr;
// 额外参数,目前用法指向AsyncSocket,用于AsyncQueue的回调
void* arg;
} sock_message_t;
char temp[SOCKET_UDP_MTU];
} sock_msg_t;

void* sock_msg_init(void* p);
void sock_msg_destroy(void* p);

// message的异步执行线程
void* sock_on_message(void* arg);

class AsyncSocket{
Expand All @@ -39,7 +45,7 @@ class AsyncSocket{
virtual void onRead();
virtual void onWrite() = 0;
virtual void onError(int error) = 0;
virtual void onMessage(sock_message_t* msg) = 0;
virtual void onMessage(sock_msg_t* msg) = 0;

protected:
int m_sock;
Expand Down
Loading

0 comments on commit 8d3738e

Please sign in to comment.