Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/ipcd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ LDFLAGS := -L$(LIB_DIR) \
-Wl,--end-group \
-lpthread -ldl -lm -lrt \
-Wl,--gc-sections \
-Wl,-rpath,/usr/lib
-Wl,-rpath,/usr/lib \
-Wl,-rpath-link,$(LIB_DIR)

# -------------------------------------------------------------------
# Sources
Expand Down Expand Up @@ -115,7 +116,9 @@ C_SOURCES := \
$(SRC_DIR)/stats.c \
$(SRC_DIR)/ir.c \
$(SRC_DIR)/cap_pipeline.c \
$(SRC_DIR)/rtsp_server.c
$(SRC_DIR)/rtsp_server.c \
$(SRC_DIR)/onvif_ptz.c \
$(SRC_DIR)/ptz_motor.c

OBJS := $(C_SOURCES:.c=.o)

Expand Down
4 changes: 4 additions & 0 deletions src/ipcd/include/ipcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ int capture_start(const struct capture_cfg *cfg);
/* Tear everything down: VI, VENC, RTSP, HLS, stream workers.
* Blocks until threads have joined. */
void capture_stop(void);
void cap_set_chroma(int color);

int capture_is_running(void);

Expand Down Expand Up @@ -503,6 +504,9 @@ int onvif_events_dispatch(const char *op, const char *query,
const char *body,
const char *host, int port,
char *out, size_t cap, size_t *out_len);
/* PTZ (onvif_ptz.c) */
size_t onvif_ptz_dispatch(const char *op, const char *body,
char *out, size_t cap);

/* Motion detection threshold — sum of per-block deltas from
* ak_vpss_md_get_stat (range 0..1536*255). Default 1500.
Expand Down
Empty file modified src/ipcd/scripts/bin2c.sh
100644 → 100755
Empty file.
64 changes: 59 additions & 5 deletions src/ipcd/src/cap_pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,30 @@ extern int ak_vpss_set_fps_level(int dev_id, const uint32_t table[9]);
* Returns 0 on success. */
extern int Ak_ISP_Set_Sensor_Fps(int dev_id, int *fps);
extern int Ak_ISP_Get_Sensor_Fps(int dev_id, int *fps);
struct isp_flip_mirror_info { int flip_en; int mirror_en; };
/* Sharpness control - reduce over-sharpening that causes edge irisation.
* Struct layout must match ak_isp_drv.h AK_ISP_SHARP exactly. */
typedef struct {
unsigned short mf_hpf_k, mf_hpf_shift, hf_hpf_k, hf_hpf_shift;
unsigned short sharp_method, sharp_skin_gain_weaken;
unsigned short sharp_skin_gain_th, sharp_skin_detect_enable, ysharp_enable;
short MF_HPF_LUT[256];
short HF_HPF_LUT[256];
} AKSHARP;
typedef struct {
unsigned short ysharp_mode;
AKSHARP manual_sharp_attr;
AKSHARP linkage_sharp_attr[9];
} AKSHARPATTR;
extern int AK_ISP_get_sharp_attr(AKSHARPATTR *p);
extern int AK_ISP_set_sharp_attr(const AKSHARPATTR *p);
extern int isp_set_flip_mirror(struct isp_flip_mirror_info *info);
extern int ak_vpss_get_sensor_fps(int dev_id, int *fps);

/* libmpi_venc.so */
extern int ak_venc_open(const struct encode_param *param, int *out_handle_id);
extern int ak_venc_close(int handle_id);
extern int ak_venc_release_stream(int handle_id, struct video_stream *vs);
extern int ak_venc_get_attr(int handle_id, struct encode_param *param);
extern int ak_venc_set_attr(int handle_id, const struct encode_param *param);

/* libapp_video.so */
extern int ak_app_video_bind_chn(struct ak_chn *src, struct ak_chn *dst,
Expand All @@ -486,7 +504,7 @@ extern int ak_app_video_venc_get_stream(struct ak_chn *dst,
/* Configuration */
/* ====================================================================== */

#define DEFAULT_SENSOR_CONFIG "/etc/config/isp_sc2331_mipi_2lane_h3b_15fps.conf"
#define DEFAULT_SENSOR_CONFIG "/etc/config/isp_f37p_mipi_1lane_h3b.conf"
#define DEFAULT_FPS 15
/* GOP length in seconds. We use 1 second (= one IDR every ~8 frames at
* effective framerate) instead of the original 2 seconds, because VLC
Expand Down Expand Up @@ -1323,7 +1341,29 @@ static int vi_init(void)
}
g_vi_dev_enabled = 1;
fprintf(stderr, "[vi] dev enabled\n");

{
struct isp_flip_mirror_info fm;
fm.flip_en = 0;
fm.mirror_en = 0;
fprintf(stderr, "[isp] isp_set_flip_mirror flip=%d mirror=%d\n", fm.flip_en, fm.mirror_en);
isp_set_flip_mirror(&fm);
}
/* reduce sharpening — kills edge color-fringing (irisation) */
{
AKSHARPATTR sh;
int _rg = AK_ISP_get_sharp_attr(&sh);
sh.ysharp_mode = 0;
sh.manual_sharp_attr.ysharp_enable = 0;
sh.manual_sharp_attr.mf_hpf_k = 0;
sh.manual_sharp_attr.hf_hpf_k = 0;
for (int _i = 0; _i < 9; _i++) {
sh.linkage_sharp_attr[_i].ysharp_enable = 0;
sh.linkage_sharp_attr[_i].mf_hpf_k = 0;
sh.linkage_sharp_attr[_i].hf_hpf_k = 0;
}
int _rs = AK_ISP_set_sharp_attr(&sh);
fprintf(stderr, "[isp] sharpening get=%d set=%d\n", _rg, _rs);
}
/* 7) Enable the channels (logs "set channel [N] capture on"). */
if (G_cfg.enable_main) {
rc = ak_vi_enable_chn(0);
Expand Down Expand Up @@ -1588,7 +1628,21 @@ int capture_start(const struct capture_cfg *cfg_in)
g_cap_super_started = 1;
return 0;
}

/* Switch encoder chroma: color=1 (day/YUV420), color=0 (night/mono).
* Matches stock anyka_ipc set_encoder_chroma_mode - fixes IR night tint. */
void cap_set_chroma(int color)
{
for (int i = 0; i < 2; i++) {
if (g_streams[i].venc_id < 0) continue;
struct encode_param ep;
memset(&ep, 0, sizeof(ep));
if (ak_venc_get_attr(g_streams[i].venc_id, &ep) == 0) {
ep.chroma_mode = color ? 1 : 0;
ak_venc_set_attr(g_streams[i].venc_id, &ep);
}
}
fprintf(stderr, "[cap] chroma -> %s\n", color ? "color" : "mono");
}
void capture_stop(void)
{
if (!g_cap_super_started) return;
Expand Down
Loading