FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Android_Native_Surface/src/recordReceive.cpp at master · SsageParuders/Android_Native_Surface · GitHub
SsageParuders
/
Android_Native_Surface
Public
Notifications
You must be signed in to change notification settings
Fork
88
Star
316
Code
Issues
6
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Android_Native_Surface
/
src
/
recordReceive.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (58 loc) · 1.85 KB
Breadcrumbs
Android_Native_Surface
/
src
/
recordReceive.cpp
Copy path
File metadata and controls
62 lines (58 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
//
Created by fgsqme on 2022/9/29.
//
#
include
"
DataDec.h
"
#
include
"
TCPServer.h
"
#
include
"
ByteUtils.h
"
#
include
"
H264Decoder.h
"
#
include
"
ImageTexture.h
"
#
include
"
draw.h
"
#
include
"
touch.h
"
//
接收h264编码流,使用ffmpeg解码到imgui显示
int
main
(
int
argc,
char
*argv[]) {
if
(!
initDraw
(
true
)) {
return
-
1
;
}
Init_touch_config
();
//
h264解码工具
H264Decoder decoder;
//
Tcp 服务
TCPServer
tcpServer
(
6656
);
//
监听客户端
TCPClient *tcpClient = tcpServer.
accept
();
//
4M缓存接收数据包用
int
bufferLen =
1024
*
1024
*
4
;
auto
*buffer =
new
mbyte[bufferLen];
DataDec
dataDec
(buffer, bufferLen);
ssize_t
err =
0
;
while
(
true
) {
drawBegin
();
//
接收头信息
err = tcpClient->
recvo
(buffer,
DataDec::headerSize
());
if
(err !=
DataDec::headerSize
()) {
printf
(
"
headerSize error: %zd
\n
"
, err);
break
;
}
//
接收数据包
int
frameLenth = dataDec.
getLength
();
//
printf("frameLenth len: %d\n", frameLenth);
err = tcpClient->
recvo
(buffer,
DataDec::headerSize
(), frameLenth,
0
);
if
(err != frameLenth) {
printf
(
"
Failed to get frame. length: %zd
\n
"
, err);
break
;
}
decoder.
decode
((
unsigned
char
*) (buffer +
DataDec::headerSize
()), frameLenth);
ImageTexture
imageTexture
(decoder.
getDecBuffer
(), decoder.
getWidth
(), decoder.
getHeight
());
ImGui::Begin
(
"
record
"
);
ImVec2 imVec2 =
ImVec2
((
float
) decoder.
getWidth
(), (
float
) decoder.
getHeight
());
ImGui::SetWindowSize
(
ImVec2
(imVec2.
x
+
100
, imVec2.
y
+
100
));
ImGui::Image
((ImTextureID) imageTexture.
getOpenglTexture
(), imVec2);
ImGui::End
();
drawEnd
();
}
tcpClient->
close
();
tcpServer.
close
();
delete[]
buffer;
shutdown
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL