⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pthread_search.c

📁 1、基于韩国at2041芯片开发的Linux环境的DVR代码。 2、以原来代码进行了修改。 3、主要修改网络通讯出现异常问题处理 4、硬盘覆盖录像不起作用
💻 C
📖 第 1 页 / 共 3 页
字号:
/* set tabstop=4 *//******************************************************************************** *                                                                              * * Copyright(C) 2004  Penta-Micro                                               * *                                                                              * * ALL RIGHT RESERVED                                                           * *                                                                              * * This software is the property of Penta-Micro and is furnished under          * * license by Penta-Micro. This software may be used only in accordance         *	 * with the terms of said license. This copyright notice may not be             * * removed, modified or obliterated without the prior written permission        * * of Penta-Micro.                                                              * *                                                                              * * This software may not be copyed, transmitted, provided to or otherwise       * * made available to any other person, company, corporation	or other entity     * * except as specified in the terms of said license.                            * *                                                                              * * No right, title, ownership or other interest in the software is hereby       * * granted or transferred.                                                      * *                                                                              * * The information contained herein is subject to change without notice and     * * should not be construed as a commitment by Penta-Micro.                      * *                                                                              * ********************************************************************************   MODULE NAME:  PTHREAD_SEARCH.C    REVISION HISTORY:    Date       Ver Name                  Description  ---------- --- --------------------- -----------------------------------------  06/30/2004 2.0 CheulBeck(whitefe)       Created     07/20/2005 2.1 JiGwanKang(xchannel)  Modified ...............................................................................   DESCRIPTION:    This Module contains functions for Search.   ...............................................................................*/   /** ************************************************************************* **  ** includes ** ************************************************************************* **/#include <stdio.h>#include <sys/vfs.h>	/* statfs() */#include "main.h"#include "pthread_search.h"/** ************************************************************************* **  ** defines ** ************************************************************************* **/#define m_DEBUG(format, args...)  printf(format, ## args) //#define m_DEBUG(format, args...)  #define m_MSG(format, args...)      printf(format, ## args) #define m_ERROR(format, args...)  printf(format, ## args);fflush(stdout);/** ************************************************************************* **  ** typedefs ** ************************************************************************* **/	 /** ************************************************************************* **  ** globals ** ************************************************************************* **/extern PTHREAD_STATE	      *gp_state_thread;extern SETUP_PARAM		*gp_setup_param;extern UNS8 MAIN_DB_NAME[32];/** ************************************************************************* **  ** locals ** ************************************************************************* **/static SEARCH_OBJECT	      *sp_search_object;/** ************************************************************************* **  ** forward declarations ** ************************************************************************* **/void *pthread_search(void *args){	UNS16			ii;		UNS16			input_value = 0;	S16				up_down;	PTHREAD_ID	start_id = 0;		PTHREAD_BUF	signal;	FUNC_ID		search;	RETURN		ret;		m_DEBUG("\t!!!! pthread SEARCH !!!!\n");		/* 1st. allocate live thread object */	if ( !(sp_search_object = (SEARCH_OBJECT *) malloc (sizeof(SEARCH_OBJECT))) ) {		m_ERROR("pthread_search.c:error In function 'malloc'\n");		return FAILURE;			}		memset(sp_search_object, 0x00, sizeof(SEARCH_OBJECT));	sp_search_object->param = gp_setup_param;	sp_search_object->search_list.mode = ALL;		// '0' All, '1' Conti, '2' Motion, '3' Sensor	sp_search_object->search_list.cur_db_fp = 0;	sp_search_object->search_list.next_db_fp = 0;	sp_search_object->search_list.start_num = 0;		sp_search_object->search_list.end_num = 0;		/* 2nd. arrange search menu function */	search.func_id[SEARCH_MAIN].func_ptr = search_main;		search.func_id[SEARCH_FILELIST].func_ptr = search_filelist;			search.func_id[SEARCH_PLAYBACK].func_ptr = search_playback;		/* 3rd. get start and enc time */	up_down = get_start_end_time(sp_search_object);	if (up_down == -1) {		m_MSG("\t!!! NO RECORDING FILE !!!\n");#if 1//add code ( not found main DB )		search_clear_menu(0);		tw2834_write_string(X_PATH, 10, 7, YELLOW, BLINK, "---  NO MAIN DB FILE  ---");		sleep(2);		signal.start_id = PTHREAD_SEARCH;		signal.m_value = 1; 				if (pthread_send_signal(&signal, PTHREAD_LIVE) == FALSE) {			m_ERROR("main.c:error: In function 'pthread_send_signal'\n");		}					gp_state_thread->state_main.state = IDLE;							return 0;		#endif	}	/* 4th. set initial search menu */	sp_search_object->prev_id = SEARCH_MAIN;	sp_search_object->cur_id = SEARCH_MAIN;	sp_search_object->next_id = SEARCH_FILELIST;		search_clear_menu(sp_search_object->cur_id);	search_create_menu(sp_search_object->cur_id);	search_select_menu(sp_search_object, up_down);	sp_search_object->create_menu = 0;	gp_state_thread->state_dec.mode_rec = ALL;		while (1) {		/* waiting signal from input thread */		pthread_read_signal(&signal, PTHREAD_SEARCH, TRUE); 		m_MSG("\tsignal> [search][id:%02d][value:0x%04x]\n", signal.start_id, signal.m_value);				/* receive start id */		sp_search_object->sig_id = signal.start_id;		sp_search_object->sig_value = signal.m_value;				switch (sp_search_object->sig_id) {			case PTHREAD_INPUT :								/* call function */						ret = search.func_id[sp_search_object->cur_id].func_ptr(sp_search_object);				if (ret == ENDING) { 											gp_state_thread->state_main.state = IDLE;					return 0;				} else if (ret == FAILURE) { 										m_ERROR("pthread_search.c:error: In function 'func_id[%d]'\n", sp_search_object->cur_id);				} 											if (sp_search_object->create_menu | sp_search_object->upgrade_menu) { #if 0//test					/* must be insert, the osd_text overwirte,  occur live_osd msg and search_osd msg simultaneously */					usleep(300);#endif					search_clear_menu(sp_search_object->cur_id);								search_create_menu(sp_search_object->cur_id);						if (sp_search_object->create_menu) {						search_select_menu(sp_search_object, 0);					} else if (sp_search_object->upgrade_menu) {						search_update_osd(sp_search_object);					}					sp_search_object->create_menu = 0;						sp_search_object->upgrade_menu = 0;					} 				break;			default :				break;		} 	} /* end of while (!QUIT_SDVR_MAIN) */		return 0;	}RETURN search_create_menu(SEARCH_ID id){	UNS16 ii = 0;	MENU_FONT_t *font;//	tw2834_osd_clear(ALL_PATH);	font = &search_menu_font[id][ii];	while (font->xstart >= 0) {		tw2834_write_string(X_PATH, font->xstart, font->ystart, NORMAL, NORMAL, font->str);     /* Warnning */		font = &search_menu_font[id][ii++];	}}void search_clear_menu(SEARCH_ID id){	tw2834_osd_clear(ALL_PATH);}void search_select_menu(SEARCH_OBJECT *pso, S16 up_down){	MENU_FONT_t *font;	if (up_down == 0) {		pso->cur_loc = search_menu_active[pso->cur_id].start;	}		font = &search_menu_font[pso->cur_id][pso->cur_loc];	tw2834_write_string(X_PATH, font->xstart, font->ystart, NORMAL, NORMAL, font->str);     	while (search_menu_font[pso->cur_id][pso->cur_loc].active >= 0) {		pso->cur_loc += up_down;		if (pso->cur_loc == -1) {			pso->cur_loc = search_menu_active[pso->cur_id].end;		}		if (search_menu_font[pso->cur_id][pso->cur_loc].active == -1) {			pso->cur_loc = 0;		} else if (search_menu_font[pso->cur_id][pso->cur_loc].active) {			break;		}	}		font = &search_menu_font[pso->cur_id][pso->cur_loc];	tw2834_write_string(X_PATH, font->xstart, font->ystart, YELLOW, BLINK , font->str);     	}void search_update_osd(SEARCH_OBJECT *pso){	MENU_FONT_t *font;	font = &search_menu_font[pso->cur_id][pso->osd_loc];	tw2834_write_string(X_PATH, font->xstart, font->ystart, font->color, font->attribute,  font->str);     }RETURN search_main(SEARCH_OBJECT *pso){	UNS16	ii;		S8		temp[8];		MENU_FONT_t 	*mft;		PTHREAD_BUF		signal;		mft = search_menu_font[pso->cur_id];		switch (pso->sig_value) {		case NUM_PLUS :			if (pso->cur_loc == VALUE_SLT_YEAR) {				pso->tm_select.tm_year ++;								sprintf(temp, "%04d", pso->tm_select.tm_year + 1900);				strcpy(mft[pso->cur_loc].str, temp);				pso->osd_loc = pso->cur_loc;									mft[pso->osd_loc].color = YELLOW;				mft[pso->osd_loc].attribute = BLINK;								search_update_osd(pso);							} else if (pso->cur_loc == VALUE_SLT_MONTH) {					pso->tm_select.tm_mon ++;				if (pso->tm_select.tm_mon > 11) {					pso->tm_select.tm_mon = 0;				}				sprintf(temp, "%02d", pso->tm_select.tm_mon + 1);				strcpy(mft[pso->cur_loc].str, temp);				pso->osd_loc = pso->cur_loc;									mft[pso->osd_loc].color = YELLOW;				mft[pso->osd_loc].attribute = BLINK;								search_update_osd(pso);							} else if (pso->cur_loc == VALUE_SLT_DAY) {				pso->tm_select.tm_mday ++;								if (pso->tm_select.tm_mday > 31) {					pso->tm_select.tm_mday = 1;				}								sprintf(temp, "%02d", pso->tm_select.tm_mday);				strcpy(mft[pso->cur_loc].str, temp);				pso->osd_loc = pso->cur_loc;									mft[pso->osd_loc].color = YELLOW;				mft[pso->osd_loc].attribute = BLINK;								search_update_osd(pso);							} else if (pso->cur_loc == VALUE_SLT_HOUR) {				pso->tm_select.tm_hour ++;					if (pso->tm_select.tm_hour > 23) {					pso->tm_select.tm_hour = 0;				}								sprintf(temp, "%02d", pso->tm_select.tm_hour);				strcpy(mft[pso->cur_loc].str, temp);				pso->osd_loc = pso->cur_loc;									mft[pso->osd_loc].color = YELLOW;				mft[pso->osd_loc].attribute = BLINK;								search_update_osd(pso);							}					break;		case NUM_MINUS : 			if (pso->cur_loc == VALUE_SLT_YEAR) {				pso->tm_select.tm_year --;								sprintf(temp, "%04d", pso->tm_select.tm_year + 1900);				strcpy(mft[pso->cur_loc].str, temp);				pso->osd_loc = pso->cur_loc;									mft[pso->osd_loc].color = YELLOW;				mft[pso->osd_loc].attribute = BLINK;								search_update_osd(pso);							} else if (pso->cur_loc == VALUE_SLT_MONTH) {					pso->tm_select.tm_mon --;				if (pso->tm_select.tm_mon < 0) {					pso->tm_select.tm_mon = 11;				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -