|
@@ -35,6 +35,7 @@ extern "C"
|
|
|
#include <opencv2/imgproc/types_c.h>
|
|
|
|
|
|
#include "rawpic.pb.h"
|
|
|
+#include "remotectrl.pb.h"
|
|
|
|
|
|
bool gbNewData = false;
|
|
|
#include <QWaitCondition>
|
|
@@ -59,6 +60,12 @@ static char * gstrwidth ="1280";
|
|
|
static char * gstrheight = "720";
|
|
|
int gnwidth,gnheight;
|
|
|
int gnframerate = 4000000;
|
|
|
+int gnframeratenow = 4000000;
|
|
|
+bool gbremotectrlframerate = true;
|
|
|
+int gnremotestate = 900; //if 30 seconds no remote message,gnframerate_percent = 1
|
|
|
+
|
|
|
+int gnframerate_percent = 100;
|
|
|
+std::string gstr_campos = "front";
|
|
|
|
|
|
void * gpaout;
|
|
|
|
|
@@ -185,7 +192,7 @@ RESTART:
|
|
|
|
|
|
|
|
|
/* put sample parameters */
|
|
|
- c->bit_rate = gnframerate;
|
|
|
+ c->bit_rate = gnframeratenow;
|
|
|
/* resolution must be a multiple of two */
|
|
|
c->width = gnwidth;
|
|
|
c->height = gnheight;
|
|
@@ -269,17 +276,24 @@ RESTART:
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- static int ntest = 0; //test change framerate.
|
|
|
- // ntest++;
|
|
|
- int64_t new_bitrate = 4000000;
|
|
|
- if(ntest > 300)
|
|
|
+
|
|
|
+ if(gbremotectrlframerate)
|
|
|
+ {
|
|
|
+ if(gnremotestate>0)gnremotestate--;
|
|
|
+ }
|
|
|
+ if(gnremotestate == 0)
|
|
|
{
|
|
|
+ gnframerate_percent = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if((gnframerate * gnframerate_percent/100 ) != gnframeratenow)
|
|
|
+ {
|
|
|
+ gnframeratenow = gnframerate * gnframerate_percent /100;
|
|
|
av_frame_free(&frame);
|
|
|
avcodec_free_context(&c);
|
|
|
av_packet_free(&pkt);
|
|
|
// 关闭原编码器
|
|
|
avcodec_close(c);
|
|
|
- gnframerate = new_bitrate;
|
|
|
goto RESTART;
|
|
|
}
|
|
|
|
|
@@ -385,6 +399,41 @@ int main(int argc, char *argv[])
|
|
|
std::string strwidth = xp.GetParam("width",std::string("1920"));
|
|
|
std::string strheight = xp.GetParam("height",std::string("1080"));
|
|
|
gnframerate = xp.GetParam("framerate",4000000);
|
|
|
+ gnframeratenow = gnframerate;
|
|
|
+
|
|
|
+ bool bremotectrlframerate = xp.GetParam("remotectrlframerate",true);
|
|
|
+ gbremotectrlframerate = bremotectrlframerate;
|
|
|
+ std::string strcampos = xp.GetParam("campos","unknown");
|
|
|
+ gstr_campos = strcampos;
|
|
|
+ if(bremotectrlframerate)
|
|
|
+ {
|
|
|
+
|
|
|
+ void * premote = iv::modulecomm::RegisterRecv("remotectrl",[](const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname){
|
|
|
+ (void)strdata;(void)nSize;(void)index;(void)dt;(void)strmemname;
|
|
|
+ gnremotestate = 900;
|
|
|
+ iv::remotectrl xremotectrl;
|
|
|
+ if(xremotectrl.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ if(xremotectrl.has_frame_percent_separate())
|
|
|
+ {
|
|
|
+ if(xremotectrl.frame_percent_separate())
|
|
|
+ {
|
|
|
+ if(gstr_campos == std::string("front"))gnframerate_percent = xremotectrl.frame_percent_front();
|
|
|
+ if(gstr_campos == std::string("rear"))gnframerate_percent = xremotectrl.frame_percent_rear();
|
|
|
+ if(gstr_campos == std::string("left"))gnframerate_percent = xremotectrl.frame_percent_left();
|
|
|
+ if(gstr_campos == std::string("right"))gnframerate_percent = xremotectrl.frame_percent_right();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ gnframerate_percent = xremotectrl.frame_percent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ (void)premote;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
gstrbuffer = new char[30000000];
|
|
|
gstrout = new char[10000000];
|