Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
offcntools
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李维杰
offcntools
Commits
3f6baeb0
Commit
3f6baeb0
authored
Jul 01, 2022
by
李维杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改逻辑
parent
b6bf8a50
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
11 deletions
+82
-11
filereader.cpp
wb_rebuild/filereader.cpp
+6
-0
rebuild_manager.cpp
wb_rebuild/rebuild_manager.cpp
+14
-4
rebuild_manager.h
wb_rebuild/rebuild_manager.h
+7
-1
wb_rebuild.cpp
wb_rebuild/wb_rebuild.cpp
+48
-6
wb_rebuild_config.ini
wb_rebuild/wb_rebuild_config.ini
+7
-0
No files found.
wb_rebuild/filereader.cpp
View file @
3f6baeb0
...
...
@@ -16,6 +16,12 @@ extern "C"
CFileReader
::
CFileReader
()
{
av_register_all
();
avformat_network_init
();
// 设置编解码库日志回调函数
av_log_set_callback
(
NULL
);
resetReader
();
}
CFileReader
::~
CFileReader
()
...
...
wb_rebuild/rebuild_manager.cpp
View file @
3f6baeb0
...
...
@@ -2,7 +2,8 @@
RebuildManager
::
RebuildManager
()
:
ZCWorkThread
(
"MediaReadThread"
),
m_pMqtt
(
nullptr
)
m_pMqtt
(
nullptr
),
m_nMqttSuccess
(
0
)
{}
RebuildManager
::~
RebuildManager
()
{
...
...
@@ -40,9 +41,12 @@ void RebuildManager::DisConnectMqttServer()
}
}
bool
RebuildManager
::
OpenMediaFile
(
std
::
string
filePath
,
std
::
string
key
)
bool
RebuildManager
::
OpenMediaFile
()
{
return
m_fileReader
.
OpenFile
(
filePath
,
key
);
int
nRet
=
m_fileReader
.
OpenFile
(
m_configData
.
FilePath
(),
m_configData
.
MediaKey
());
if
(
nRet
!=
0
)
return
false
;
return
true
;
}
void
RebuildManager
::
CloseMediaFile
()
{
...
...
@@ -58,6 +62,10 @@ void RebuildManager::StopPull()
{
StopThread
();
}
bool
RebuildManager
::
EndOfFile
()
{
return
m_fileReader
.
GetEof
();
}
void
RebuildManager
::
DoRunning
()
{
if
(
!
m_fileReader
.
GetEof
())
...
...
@@ -92,6 +100,8 @@ void RebuildManager::DoRunning()
void
RebuildManager
::
OnConnectServerSuccess
(
bool
success
)
{
m_nMqttSuccess
=
success
?
1
:
2
;
if
(
success
)
{
printf
(
"mqtt : connect mqtt server sucess ...
\n
"
);
...
...
@@ -128,7 +138,7 @@ void RebuildManager::CallBackWhiteBoardData(AVPacket &pkt)
std
::
string
req
((
char
*
)
info
.
m_pData
+
6
,
info
.
m_nDataSize
-
6
);
int
index
=
*
(
int
*
)(
info
.
m_pData
+
6
+
8
);
printf
(
"
---------------
%d
\n
"
,
index
);
printf
(
"
whitebaord's data index =
%d
\n
"
,
index
);
if
(
m_pMqtt
)
{
...
...
wb_rebuild/rebuild_manager.h
View file @
3f6baeb0
...
...
@@ -18,13 +18,16 @@ public:
bool
ConnectMqttServer
();
void
DisConnectMqttServer
();
int
Connected
()
{
return
m_nMqttSuccess
;
}
bool
OpenMediaFile
(
std
::
string
filePath
,
std
::
string
key
);
bool
OpenMediaFile
();
void
CloseMediaFile
();
bool
StartPull
();
void
StopPull
();
bool
EndOfFile
();
private
:
virtual
void
DoRunning
();
...
...
@@ -49,7 +52,10 @@ private:
private
:
GlobalData
m_configData
;
private
:
CmdTransportMqtt
*
m_pMqtt
;
int
m_nMqttSuccess
;
private
:
CFileReader
m_fileReader
;
...
...
wb_rebuild/wb_rebuild.cpp
View file @
3f6baeb0
...
...
@@ -2,21 +2,63 @@
//
#include <iostream>
#include "
global_data
.h"
#include "
rebuild_manager
.h"
int
main
()
{
GlobalData
config
;
if
(
!
config
.
LoadConfigFile
())
RebuildManager
*
manager
=
new
RebuildManager
()
;
if
(
!
manager
->
Init
())
{
goto
WaitFlag
;
printf
(
"init failed ...
\n
"
);
delete
manager
;
goto
Error
;
}
printf
(
"init ok ...
\n
"
);
if
(
!
manager
->
ConnectMqttServer
())
{
delete
manager
;
printf
(
"connect mqtt failed ...
\n
"
);
goto
Error
;
}
while
(
manager
->
Connected
()
==
0
)
{
printf
(
"wait connect mqtt resualt ...
\n
"
);
std
::
chrono
::
milliseconds
dura
(
1000
);
std
::
this_thread
::
sleep_for
(
dura
);
}
if
(
manager
->
Connected
()
==
1
)
{
printf
(
"connect mqtt server success ...
\n
"
);
}
else
{
delete
manager
;
goto
Error
;
}
if
(
!
manager
->
OpenMediaFile
())
{
printf
(
"open media file failed ...
\n
"
);
goto
Error
;
}
WaitFlag
:
manager
->
StartPull
();
while
(
!
manager
->
EndOfFile
())
{
std
::
chrono
::
milliseconds
dura
(
1000
);
std
::
this_thread
::
sleep_for
(
dura
);
}
manager
->
StopPull
();
manager
->
CloseMediaFile
();
manager
->
DisConnectMqttServer
();
Error
:
printf
(
"Press enter key to exit ...
\n
"
);
getchar
();
return
0
;
}
wb_rebuild/wb_rebuild_config.ini
0 → 100644
View file @
3f6baeb0
{
"roomid":"3ae42ba21356a02a9535092b0c6b777b",
"uuid":"liweijieisvip_309",
"filepath":"https://vod-live.offcncloud.com/vod/20211109037879836/vod/47a480ebd9a2c46912ac21836aaeb22e/index.m3u8",
"key":"7b539939e9103688"
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment