mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-26 23:36:16 +00:00
refactoring
This commit is contained in:
@@ -42,8 +42,8 @@
|
|||||||
#include "encoder.h"
|
#include "encoder.h"
|
||||||
|
|
||||||
|
|
||||||
#define INPUT_PORT 340
|
static const OMX_U32 _INPUT_PORT = 340;
|
||||||
#define OUTPUT_PORT 341
|
static const OMX_U32 _OUTPUT_PORT = 341;
|
||||||
|
|
||||||
|
|
||||||
static int _i_omx = 0;
|
static int _i_omx = 0;
|
||||||
@@ -300,7 +300,7 @@ static int _omx_setup_input(struct omx_encoder_t *omx, struct device_t *dev) {
|
|||||||
|
|
||||||
LOG_DEBUG("Setting up OMX JPEG input port ...");
|
LOG_DEBUG("Setting up OMX JPEG input port ...");
|
||||||
|
|
||||||
if (component_get_portdef(&omx->encoder, &portdef, INPUT_PORT) < 0) {
|
if (component_get_portdef(&omx->encoder, &portdef, _INPUT_PORT) < 0) {
|
||||||
LOG_ERROR("... first");
|
LOG_ERROR("... first");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -338,17 +338,17 @@ static int _omx_setup_input(struct omx_encoder_t *omx, struct device_t *dev) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_get_portdef(&omx->encoder, &portdef, INPUT_PORT) < 0) {
|
if (component_get_portdef(&omx->encoder, &portdef, _INPUT_PORT) < 0) {
|
||||||
LOG_ERROR("... second");
|
LOG_ERROR("... second");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_enable_port(&omx->encoder, INPUT_PORT) < 0) {
|
if (component_enable_port(&omx->encoder, _INPUT_PORT) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
omx->i_input_port_enabled = true;
|
omx->i_input_port_enabled = true;
|
||||||
|
|
||||||
if ((error = OMX_AllocateBuffer(omx->encoder, &omx->input_buffer, INPUT_PORT, NULL, portdef.nBufferSize)) != OMX_ErrorNone) {
|
if ((error = OMX_AllocateBuffer(omx->encoder, &omx->input_buffer, _INPUT_PORT, NULL, portdef.nBufferSize)) != OMX_ErrorNone) {
|
||||||
LOG_OMX_ERROR(error, "Can't allocate OMX JPEG input buffer");
|
LOG_OMX_ERROR(error, "Can't allocate OMX JPEG input buffer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality) {
|
|||||||
|
|
||||||
LOG_DEBUG("Setting up OMX JPEG output port ...");
|
LOG_DEBUG("Setting up OMX JPEG output port ...");
|
||||||
|
|
||||||
if (component_get_portdef(&omx->encoder, &portdef, OUTPUT_PORT) < 0) {
|
if (component_get_portdef(&omx->encoder, &portdef, _OUTPUT_PORT) < 0) {
|
||||||
LOG_ERROR("... first");
|
LOG_ERROR("... first");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_get_portdef(&omx->encoder, &portdef, OUTPUT_PORT) < 0) {
|
if (component_get_portdef(&omx->encoder, &portdef, _OUTPUT_PORT) < 0) {
|
||||||
LOG_ERROR("... second");
|
LOG_ERROR("... second");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -395,7 +395,7 @@ static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality) {
|
|||||||
OMX_PARAM_IJGSCALINGTYPE ijg;
|
OMX_PARAM_IJGSCALINGTYPE ijg;
|
||||||
|
|
||||||
OMX_INIT_STRUCTURE(ijg);
|
OMX_INIT_STRUCTURE(ijg);
|
||||||
ijg.nPortIndex = OUTPUT_PORT;
|
ijg.nPortIndex = _OUTPUT_PORT;
|
||||||
ijg.bEnabled = OMX_TRUE;
|
ijg.bEnabled = OMX_TRUE;
|
||||||
|
|
||||||
if ((error = OMX_SetParameter(omx->encoder, OMX_IndexParamBrcmEnableIJGTableScaling, &ijg)) != OMX_ErrorNone) {
|
if ((error = OMX_SetParameter(omx->encoder, OMX_IndexParamBrcmEnableIJGTableScaling, &ijg)) != OMX_ErrorNone) {
|
||||||
@@ -408,7 +408,7 @@ static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality) {
|
|||||||
OMX_IMAGE_PARAM_QFACTORTYPE qfactor;
|
OMX_IMAGE_PARAM_QFACTORTYPE qfactor;
|
||||||
|
|
||||||
OMX_INIT_STRUCTURE(qfactor);
|
OMX_INIT_STRUCTURE(qfactor);
|
||||||
qfactor.nPortIndex = OUTPUT_PORT;
|
qfactor.nPortIndex = _OUTPUT_PORT;
|
||||||
qfactor.nQFactor = quality;
|
qfactor.nQFactor = quality;
|
||||||
|
|
||||||
if ((error = OMX_SetParameter(omx->encoder, OMX_IndexParamQFactor, &qfactor)) != OMX_ErrorNone) {
|
if ((error = OMX_SetParameter(omx->encoder, OMX_IndexParamQFactor, &qfactor)) != OMX_ErrorNone) {
|
||||||
@@ -417,12 +417,12 @@ static int _omx_setup_output(struct omx_encoder_t *omx, unsigned quality) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_enable_port(&omx->encoder, OUTPUT_PORT) < 0) {
|
if (component_enable_port(&omx->encoder, _OUTPUT_PORT) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
omx->i_output_port_enabled = true;
|
omx->i_output_port_enabled = true;
|
||||||
|
|
||||||
if ((error = OMX_AllocateBuffer(omx->encoder, &omx->output_buffer, OUTPUT_PORT, NULL, portdef.nBufferSize)) != OMX_ErrorNone) {
|
if ((error = OMX_AllocateBuffer(omx->encoder, &omx->output_buffer, _OUTPUT_PORT, NULL, portdef.nBufferSize)) != OMX_ErrorNone) {
|
||||||
LOG_OMX_ERROR(error, "Can't allocate OMX JPEG output buffer");
|
LOG_OMX_ERROR(error, "Can't allocate OMX JPEG output buffer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -434,23 +434,23 @@ static int _omx_encoder_clear_ports(struct omx_encoder_t *omx) {
|
|||||||
int retcode = 0;
|
int retcode = 0;
|
||||||
|
|
||||||
if (omx->i_output_port_enabled) {
|
if (omx->i_output_port_enabled) {
|
||||||
retcode -= component_disable_port(&omx->encoder, OUTPUT_PORT);
|
retcode -= component_disable_port(&omx->encoder, _OUTPUT_PORT);
|
||||||
omx->i_output_port_enabled = false;
|
omx->i_output_port_enabled = false;
|
||||||
}
|
}
|
||||||
if (omx->i_input_port_enabled) {
|
if (omx->i_input_port_enabled) {
|
||||||
retcode -= component_disable_port(&omx->encoder, INPUT_PORT);
|
retcode -= component_disable_port(&omx->encoder, _INPUT_PORT);
|
||||||
omx->i_input_port_enabled = false;
|
omx->i_input_port_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (omx->input_buffer) {
|
if (omx->input_buffer) {
|
||||||
if ((error = OMX_FreeBuffer(omx->encoder, INPUT_PORT, omx->input_buffer)) != OMX_ErrorNone) {
|
if ((error = OMX_FreeBuffer(omx->encoder, _INPUT_PORT, omx->input_buffer)) != OMX_ErrorNone) {
|
||||||
LOG_OMX_ERROR(error, "Can't free OMX JPEG input buffer");
|
LOG_OMX_ERROR(error, "Can't free OMX JPEG input buffer");
|
||||||
// retcode -= 1;
|
// retcode -= 1;
|
||||||
}
|
}
|
||||||
omx->input_buffer = NULL;
|
omx->input_buffer = NULL;
|
||||||
}
|
}
|
||||||
if (omx->output_buffer) {
|
if (omx->output_buffer) {
|
||||||
if ((error = OMX_FreeBuffer(omx->encoder, OUTPUT_PORT, omx->output_buffer)) != OMX_ErrorNone) {
|
if ((error = OMX_FreeBuffer(omx->encoder, _OUTPUT_PORT, omx->output_buffer)) != OMX_ErrorNone) {
|
||||||
LOG_OMX_ERROR(error, "Can't free OMX JPEG output buffer");
|
LOG_OMX_ERROR(error, "Can't free OMX JPEG output buffer");
|
||||||
// retcode -= 1;
|
// retcode -= 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@
|
|||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
|
|
||||||
static const char _short_opts[] = "d:i:x:y:m:a:f:z:tb:w:q:c:s:p:u:ro:e:h";
|
static const char _SHORT_OPTS[] = "d:i:x:y:m:a:f:z:tb:w:q:c:s:p:u:ro:e:h";
|
||||||
static const struct option _long_opts[] = {
|
static const struct option _LONG_OPTS[] = {
|
||||||
{"device", required_argument, NULL, 'd'},
|
{"device", required_argument, NULL, 'd'},
|
||||||
{"input", required_argument, NULL, 'i'},
|
{"input", required_argument, NULL, 'i'},
|
||||||
{"width", required_argument, NULL, 'x'},
|
{"width", required_argument, NULL, 'x'},
|
||||||
@@ -232,7 +232,7 @@ static int _parse_options(int argc, char *argv[], struct device_t *dev, struct e
|
|||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
log_level = LOG_LEVEL_INFO;
|
log_level = LOG_LEVEL_INFO;
|
||||||
while ((ch = getopt_long(argc, argv, _short_opts, _long_opts, &index)) >= 0) {
|
while ((ch = getopt_long(argc, argv, _SHORT_OPTS, _LONG_OPTS, &index)) >= 0) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'd': OPT_SET(dev->path, optarg);
|
case 'd': OPT_SET(dev->path, optarg);
|
||||||
case 'i': OPT_UNSIGNED(dev->input, "--input", 0, 128);
|
case 'i': OPT_UNSIGNED(dev->input, "--input", 0, 128);
|
||||||
|
|||||||
Reference in New Issue
Block a user