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

📄 datetime.c

📁 Dvbstreamer 用在解析MPTS的部分内容
💻 C
字号:
/*Copyright (C) 2006  Adam CharrettThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USAdatetime.cExample plugin to print out the date/time from the TDT.*/#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <string.h>#include <stdint.h>#include "logging.h"#include "plugin.h"#include "dvbpsi/datetime.h"#include "dvbpsi/tdttot.h"/******************************************************************************** Prototypes                                                                   ********************************************************************************/static void ProcessTDT(dvbpsi_tdt_tot_t *tdt);static void CommandDateTime(int argc, char **argv);/******************************************************************************** Global variables                                                             ********************************************************************************/static dvbpsi_tdt_tot_t lastDateTime;static time_t lastReceived = 0;/******************************************************************************** Plugin Setup                                                                 ********************************************************************************/PLUGIN_FEATURES(    PLUGIN_FEATURE_TDTPROCESSOR(ProcessTDT));PLUGIN_COMMANDS(    {        "date",        FALSE, 0, 0,        "Display the last date/time received.",        "Display the last date/time received.",        CommandDateTime    });PLUGIN_INTERFACE_CF(    PLUGIN_FOR_DVB,    "Date/Time",     "0.1",     "Example plugin that uses the TDT/TOT.",     "charrea6@users.sourceforge.net");/******************************************************************************** NIT Processing Function                                                      ********************************************************************************/static void ProcessTDT(dvbpsi_tdt_tot_t *tdt){    lastDateTime = *tdt;    /*    Simple structure copy won't copy the descriptors and these will be free'd    when the call back returns     */    lastDateTime.p_first_descriptor = NULL;     lastReceived = time(NULL);}/******************************************************************************** Command Functions                                                            ********************************************************************************/static void CommandDateTime(int argc, char **argv){    if (lastReceived)    {        CommandPrintf("UTC Date/Time (YYYY/MM/DD hh:mm:ss) %4d/%2d/%2d %02d:%02d:%02d\n",            lastDateTime.t_date_time.i_year, lastDateTime.t_date_time.i_month, lastDateTime.t_date_time.i_day,            lastDateTime.t_date_time.i_hour, lastDateTime.t_date_time.i_minute, lastDateTime.t_date_time.i_second);                CommandPrintf("Last received %d seconds ago.\n", time(NULL) - lastReceived);    }    else    {        CommandPrintf("No date/time has been received!\n");    }}

⌨️ 快捷键说明

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