Skip to content

Commit

Permalink
various codecs support (e.g H.264, HEVC, VP8, VP9, MJPEG, ...)
Browse files Browse the repository at this point in the history
- extends nhve_hw_config with encoder field
- following similar extension of HVE

Related to #1
  • Loading branch information
bmegli committed Jan 9, 2020
1 parent 521bbdb commit a58d17f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/nhve_stream_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const int HEIGHT=360;
const int FRAMERATE=30;
int SECONDS=10;
const char *DEVICE; //NULL for default or device e.g. "/dev/dri/renderD128"
const char *ENCODER=NULL;//NULL for default (h264_vaapi) or FFmpeg encoder e.g. "hevc_vaapi", ...
const char *PIXEL_FORMAT="nv12"; //NULL / "" for default (NV12) or pixel format e.g. "rgb0"
const int PROFILE=FF_PROFILE_H264_HIGH; //or FF_PROFILE_H264_MAIN, FF_PROFILE_H264_CONSTRAINED_BASELINE, ...
const int BFRAMES=0; //max_b_frames, set to 0 to minimize latency, non-zero to minimize size
Expand All @@ -43,7 +44,7 @@ int main(int argc, char* argv[])

//prepare library data
struct nhve_net_config net_config = {IP, PORT};
struct nhve_hw_config hw_config = {WIDTH, HEIGHT, FRAMERATE, DEVICE, PIXEL_FORMAT, PROFILE, BFRAMES, BITRATE};
struct nhve_hw_config hw_config = {WIDTH, HEIGHT, FRAMERATE, DEVICE, ENCODER, PIXEL_FORMAT, PROFILE, BFRAMES, BITRATE};
struct nhve *streamer;

//initialize library with nhve_init
Expand Down
2 changes: 1 addition & 1 deletion hardware-video-encoder
4 changes: 2 additions & 2 deletions nhve.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* NHVE Network Hardware Video Encoder C library implementation
*
* Copyright 2019 (C) Bartosz Meglicki <[email protected]>
* Copyright 2019-2020 (C) Bartosz Meglicki <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -31,7 +31,7 @@ struct nhve *nhve_init(const struct nhve_net_config *net_config,const struct nhv
struct nhve *n, zero_nhve = {0};
struct mlsp_config mlsp_cfg = {net_config->ip, net_config->port, 0};
struct hve_config hve_cfg = {hw_config->width, hw_config->height, hw_config->framerate, hw_config->device,
hw_config->pixel_format, hw_config->profile, hw_config->max_b_frames, hw_config->bit_rate};
hw_config->encoder, hw_config->pixel_format, hw_config->profile, hw_config->max_b_frames, hw_config->bit_rate};

if( ( n = (struct nhve*)malloc(sizeof(struct nhve))) == NULL )
{
Expand Down
3 changes: 2 additions & 1 deletion nhve.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* NHVE Network Hardware Video Encoder C library header
*
* Copyright 2019 (C) Bartosz Meglicki <[email protected]>
* Copyright 2019-2020 (C) Bartosz Meglicki <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -28,6 +28,7 @@ struct nhve_hw_config
int height; //!< height of the encoded frames
int framerate; //!< framerate of the encoded video
const char *device; //!< NULL / "" or device, e.g. "/dev/dri/renderD128"
const char *encoder; //!< NULL / "" or encoder, e.g. "h264_vaapi"
const char *pixel_format; //!< NULL / "" for NV12 or format, e.g. "rgb0", "bgr0", "nv12", "yuv420p"
int profile; //!< 0 to guess from input or profile e.g. FF_PROFILE_H264_MAIN, FF_PROFILE_H264_HIGH
int max_b_frames; //!< maximum number of B-frames between non-B-frames (disable if you need low latency)
Expand Down

0 comments on commit a58d17f

Please sign in to comment.