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

📄 cmd_info.c

📁 Dvbstreamer 用在解析MPTS的部分内容
💻 C
📖 第 1 页 / 共 2 页
字号:
/*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, USAinfo.cCommand functions to supply the user with information about the system.*/#define _GNU_SOURCE#include <limits.h>#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <pthread.h>#include <getopt.h>#include <ctype.h>#include <time.h>#include <errno.h>#include <readline/readline.h>#include <readline/history.h>#include "commands.h"#include "multiplexes.h"#include "services.h"#include "dvb.h"#include "ts.h"#include "logging.h"#include "cache.h"#include "main.h"#include "deliverymethod.h"#include "plugin.h"#include "servicefilter.h"#include "tuning.h"/******************************************************************************** Defines                                                                      ********************************************************************************/#define FILTER_TYPE_NOT_USED 0#define FILTER_TYPE_TV       1#define FILTER_TYPE_RADIO    2#define FILTER_TYPE_DATA     4#define FILTER_TYPE_UNKNOWN  8#define FILTER_ACCESS_NOT_USED 0#define FILTER_ACCESS_FTA      1#define FILTER_ACCESS_CA       2/******************************************************************************** Prototypes                                                                   ********************************************************************************/static void CommandListServices(int argc, char **argv);static bool FilterService(Service_t *service, uint32_t filterByType, uint32_t filterByAccess, char* provider);static void CommandListMuxes(int argc, char **argv);static void CommandListPids(int argc, char **argv);static char *GetStreamTypeString(int type);static void CommandCurrent(int argc, char **argv);static void CommandServiceInfo(int argc, char **argv);static void CommandMuxInfo(int argc, char **argv);static void CommandStats(int argc, char **argv);static void CommandFEStatus(int argc, char **argv);static void CommandVariableUptimeGet(char *name);static void CommandVariableFETypeGet(char *name);static void CommandVariableFENameGet(char *name);static void CommandVariableTSModeGet(char *name);/******************************************************************************** Global variables                                                             ********************************************************************************/Command_t CommandDetailsInfo[] ={    {        "lsservices",        TRUE, 0, 6,        "List all services or for a specific multiplex.",        "lsservices [-id] [filters] [multiplex]\n"        "Lists selected services, by default all services on all multiplex are displayed.\n"        "\n"        "-id\n"        "List the services fully quailified id.\n"        "\n"        "filters (tv, radio, data, unknown)\n"        "Multiple filters can be specified or if no filters are specified all selected"        " services will be displayed\n"        "\n"        "multiplex (\'mux\'| uid | netid.tsid | frequency)\n"        "Select only services on the specified multiplex, where \'mux\' indiciated the current multiplex.",        CommandListServices    },    {        "lsmuxes",        TRUE, 0, 1,        "List multiplexes.",        "lsmuxes [-id]\n"        "List all available multiplex UIDs.\n"        "\n"        "-id\n"        "List the multiplexes network id.ts id",        CommandListMuxes    },    {        "lspids",        TRUE, 1, 2,        "List the PIDs for a specified service.",        "lspids <service name>\n"        "List all the PIDs specified in <service name> PMT.",        CommandListPids    },        {        "current",        FALSE, 0, 0,        "Print out the service currently being streamed.",        "Shows the service that is currently being streamed to the default output.",        CommandCurrent    },    {        "serviceinfo",        FALSE, 1, 1,        "Display information about a service.",        "serviceinfo <service name>\n"        "Displays information about the specified service.",        CommandServiceInfo    },    {        "muxinfo",        TRUE, 1, 2,        "Display information about a mux.",        "muxinfo <uid> or\n"        "muxinfo <netid>.<tsid>\n"        "muxinfo <net id> <ts id>\n"        "Displays information about the specified service.",        CommandMuxInfo    },    {        "stats",        FALSE, 0, 0,        "Display the stats for the PAT,PMT and service PID filters.",        "Display the number of packets processed for the PSI/SI filters and the number of"        " packets filtered for each service filter and manual output.",        CommandStats    },    {        "festatus",        FALSE, 0, 0,        "Displays the status of the tuner.",        "Displays whether the front end is locked, the bit error rate and signal to noise"        "ratio and the signal strength",        CommandFEStatus    },    {NULL, FALSE, 0, 0, NULL,NULL}};static char *FETypesStr[] = {    "QPSK",    "QAM",    "OFDM",    "ATSC"};static CommandVariable_t VariableUptime = {    "uptime",     "Number of days/hours/minutes/seconds this instance has been running.",     CommandVariableUptimeGet,     NULL    };static CommandVariable_t VariableUpsecs = {    "upsecs",     "Number of seconds this instance has been running.",    CommandVariableUptimeGet,     NULL    };static CommandVariable_t VariableFEType = {    "fetype",     "Type of the tuner this instance is using.",    CommandVariableFETypeGet,     NULL    };static CommandVariable_t VariableFEName = {    "fename",     "Name of the tuner this instance is using.",    CommandVariableFENameGet,     NULL    };static CommandVariable_t VariableTSMode = {    "tsmode",     "Whether this instance is running in Full TS or hardware restricted mode.",    CommandVariableTSModeGet,     NULL    };static time_t StartTime;/******************************************************************************** Global functions                                                             ********************************************************************************/void CommandInstallInfo(void){    CommandRegisterCommands(CommandDetailsInfo);        CommandRegisterVariable(&VariableUptime);    CommandRegisterVariable(&VariableUpsecs);        CommandRegisterVariable(&VariableFEType);    CommandRegisterVariable(&VariableFEName);        CommandRegisterVariable(&VariableTSMode);        StartTime = time(NULL);}void CommandUnInstallInfo(void){    CommandUnRegisterCommands(CommandDetailsInfo);     CommandUnRegisterVariable(&VariableUptime);    CommandUnRegisterVariable(&VariableUpsecs);        CommandUnRegisterVariable(&VariableFEType);    CommandUnRegisterVariable(&VariableFEName);        CommandUnRegisterVariable(&VariableTSMode);     }/******************************************************************************** Local Functions                                                              ********************************************************************************/static void CommandListServices(int argc, char **argv){    ServiceEnumerator_t enumerator = NULL;    Service_t *service;    Multiplex_t *multiplex = NULL;    int i;    bool dvbIds = FALSE;    uint32_t filterByType = FILTER_TYPE_NOT_USED;    uint32_t filterByAccess = FILTER_ACCESS_NOT_USED;    char *provider = NULL;    char *providerStr = "provider=";    /* Make sure the database is up-to-date before displaying the names */    UpdateDatabase();    for (i = 0; i < argc; i ++)    {        if (strcmp(argv[i], "-id") == 0)        {            dvbIds = TRUE;        }        else if (strcmp(argv[i], "mux") == 0)        {            if (multiplex)            {                MultiplexRefDec(multiplex);            }            multiplex = TuningCurrentMultiplexGet();            if (!multiplex)            {                CommandPrintf("No multiplex currently selected!\n");                return;            }        }        else if (strcmp(argv[i], "tv") == 0)        {            filterByType |= FILTER_TYPE_TV;        }        else if (strcmp(argv[i], "radio") == 0)        {            filterByType |= FILTER_TYPE_RADIO;        }        else if (strcmp(argv[i], "data") == 0)        {            filterByType |= FILTER_TYPE_DATA;        }        else if (strcmp(argv[i], "unknown") == 0)        {            filterByType |= FILTER_TYPE_UNKNOWN;        }        else if (strcmp(argv[i], "fta") == 0)        {            filterByAccess |= FILTER_ACCESS_FTA;        }        else if (strcmp(argv[i], "ca") == 0)        {            filterByAccess |= FILTER_ACCESS_CA;        }        else if (strncmp(argv[i], providerStr, strlen(providerStr)) == 0)        {            provider = argv[i] + strlen(providerStr);        }        else        {            if (multiplex)            {                MultiplexRefDec(multiplex);            }            multiplex = MultiplexFind(argv[i]);            if (!multiplex)            {                CommandPrintf("Failed to find multiplex \"%s\"\n", argv[i]);                return;                                }                    }    }    if (multiplex)    {        enumerator = ServiceEnumeratorForMultiplex(multiplex);        MultiplexRefDec(multiplex);    }        else    {        enumerator = ServiceEnumeratorGet();    }    if (enumerator != NULL)    {        do        {            service = ServiceGetNext(enumerator);            if (service)            {                if (FilterService(service, filterByType, filterByAccess, provider))                {                    if (dvbIds)                    {                        multiplex = MultiplexFindUID(service->multiplexUID);                        CommandPrintf("%04x.%04x.%04x : %s\n",                             multiplex->networkId & 0xffff, multiplex->tsId & 0xffff,                            service->id, service->name);                        MultiplexRefDec(multiplex);                    }                    else                    {                        CommandPrintf("%s\n", service->name);                    }                }                ServiceRefDec(service);            }        }        while(service && !ExitProgram);        ServiceEnumeratorDestroy(enumerator);    }}static bool FilterService(Service_t *service, uint32_t filterByType, uint32_t filterByAccess, char* provider){    bool filterByTypeResult = FALSE;    bool filterByAccessResult = FALSE;    bool filterByProviderResult = FALSE;        if (filterByType)    {        if ((filterByType & FILTER_TYPE_TV )&& (service->type == ServiceType_TV))        {            filterByTypeResult = TRUE;        }        if ((filterByType & FILTER_TYPE_RADIO)&& (service->type == ServiceType_Radio))        {            filterByTypeResult = TRUE;        }        if ((filterByType & FILTER_TYPE_DATA)&& (service->type == ServiceType_Data))        {            filterByTypeResult = TRUE;

⌨️ 快捷键说明

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