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

📄 video_dialog.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ *  * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. *  * The Original Code is MPEG4IP. *  * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2001-2005.  All Rights Reserved. *  * Contributor(s):  *		Dave Mackie		dmackie@cisco.com *		Bill May 		wmay@cisco.com */#define __STDC_LIMIT_MACROS#include "mp4live.h"#include "mp4live_gui.h"#include "video_v4l_source.h"#include "support.h"// source definesGtkWidget *VideoSourceDialog;static const char** inputNames = NULL;static u_int8_t inputNumber = 0;	// how many inputs totalstatic CVideoCapabilities* pVideoCaps;static bool source_modified;static const char* source_type;// profile definesstatic GtkWidget *VideoProfileDialog = NULL;static const char **encoderNames = NULL;static u_int16_t* sizeWidthValues;static u_int16_t  sizeWidthValueCnt;static u_int16_t* sizeHeightValues;static u_int16_t  sizeHeightValueCnt;static u_int8_t sizeIndex;static u_int8_t sizeMaxIndex;static float aspectValues[] = {	VIDEO_STD_ASPECT_RATIO, VIDEO_LB1_ASPECT_RATIO, 	VIDEO_LB2_ASPECT_RATIO, VIDEO_LB3_ASPECT_RATIO}; static const char* aspectNames[] = {	"Standard 4:3", "Letterbox 2.35", "Letterbox 1.85", "HDTV 16:9"};static const char *profilefilterNames[] = {  VIDEO_FILTER_NONE, VIDEO_FILTER_DEINTERLACE,#ifdef HAVE_FFMPEG  VIDEO_FILTER_FFMPEG_DEINTERLACE_INPLACE,#endif};static bool ValidateAndSave(void){  GtkWidget *wid;  // if previewing, stop video source  //AVFlow->StopVideoPreview();  wid = lookup_widget(VideoSourceDialog, "VideoSourceFilter");      MyConfig->SetStringValue(CONFIG_VIDEO_FILTER, 			   gtk_option_menu_get_history(GTK_OPTION_MENU(wid)) == 0 ?			   VIDEO_FILTER_NONE : VIDEO_FILTER_DECIMATE);  // copy new values to config  wid = lookup_widget(VideoSourceDialog, "VideoSourceFile");  const char *source_name = gtk_entry_get_text(GTK_ENTRY(wid));  if (strcmp(source_name, 	     MyConfig->GetStringValue(CONFIG_VIDEO_SOURCE_NAME)) != 0) {    MyConfig->SetStringValue(CONFIG_VIDEO_SOURCE_TYPE,			     source_type);        MyConfig->SetStringValue(CONFIG_VIDEO_SOURCE_NAME,			     gtk_entry_get_text(GTK_ENTRY(wid)));#if 0    MyConfig->UpdateFileHistory(				gtk_entry_get_text(GTK_ENTRY(source_entry)));#endif    if (MyConfig->m_videoCapabilities != pVideoCaps) {      // don't do this any more - save old delete MyConfig->m_videoCapabilities;      MyConfig->m_videoCapabilities = pVideoCaps;      pVideoCaps = NULL;    }  #if 0    if (strcasecmp(source_type, VIDEO_SOURCE_V4L) 	&& default_file_audio_source >= 0) {		MyConfig->SetStringValue(CONFIG_AUDIO_SOURCE_TYPE,			source_type);		MyConfig->SetStringValue(CONFIG_AUDIO_SOURCE_NAME,			gtk_entry_get_text(GTK_ENTRY(source_entry)));		MyConfig->SetIntegerValue(CONFIG_AUDIO_SOURCE_TRACK,			default_file_audio_source);	}#endif  }    wid = lookup_widget(VideoSourceDialog, "VideoSourcePort");    MyConfig->SetIntegerValue(CONFIG_VIDEO_INPUT,			      gtk_option_menu_get_history(GTK_OPTION_MENU(wid)));    wid = lookup_widget(VideoSourceDialog, "VideoSourceSignal");    MyConfig->SetIntegerValue(CONFIG_VIDEO_SIGNAL,			      gtk_option_menu_get_history(GTK_OPTION_MENU(wid)));    wid = lookup_widget(VideoSourceDialog, "VideoSourceChannelType");    uint channelListIndex =       gtk_option_menu_get_history(GTK_OPTION_MENU(wid));    MyConfig->SetIntegerValue(CONFIG_VIDEO_CHANNEL_LIST_INDEX,			      channelListIndex);    // extract channel index out of combo (not so simple)    GtkWidget* combo = lookup_widget(VideoSourceDialog, "VideoSourceChannel");    GtkWidget* entry = GTK_COMBO(combo)->entry;    const char* channelName = gtk_entry_get_text(GTK_ENTRY(entry));    uint channelIndex = MyConfig->GetIntegerValue(CONFIG_VIDEO_CHANNEL_INDEX);    struct CHANLISTS* pChannelList = chanlists;    for (uint i = 0; i < pChannelList[channelListIndex].count; i++) {      if (!strcmp(channelName, 		  pChannelList[channelListIndex].list[i].name)) {	channelIndex = i;	break;      }    }    MyConfig->SetIntegerValue(CONFIG_VIDEO_CHANNEL_INDEX,			      channelIndex);#if 0    MyConfig->SetIntegerValue(CONFIG_VIDEO_SOURCE_TRACK,			      trackValues ? trackValues[trackIndex] : 0);#endif    MyConfig->Update();    // restart video source    if (MyConfig->GetBoolValue(CONFIG_VIDEO_ENABLE)) {      //AVFlow->StartVideoPreview();      AVFlow->RestartVideo();    }    MainWindowDisplaySources();    return true;}// forward declarationsstatic void SetAvailableSignals(void){  u_int8_t ix = 0;  u_int8_t validSignalIndex = 0xFF;  uint inputIndex;  uint signalIndex;  GtkWidget *temp, *signal_menu;  temp = lookup_widget(VideoSourceDialog, "VideoSourcePort");  inputIndex = gtk_option_menu_get_history(GTK_OPTION_MENU(temp));  signal_menu = lookup_widget(VideoSourceDialog, "VideoSourceSignal");  signalIndex = gtk_option_menu_get_history(GTK_OPTION_MENU(signal_menu));    for (ix = VIDEO_SIGNAL_PAL; ix < VIDEO_SIGNAL_MAX; ix++) {    // all signals are enabled    bool enabled = true;        // unless input is a tuner    if (pVideoCaps != NULL	&& pVideoCaps->m_inputHasTuners[inputIndex]) {            // this signal type is valid for this tuner      debug_message("Available signals for tuners %x", 		    pVideoCaps->m_inputTunerSignalTypes[inputIndex]);      if (pVideoCaps->m_inputTunerSignalTypes[inputIndex] & (1 << ix)) {		// remember first valid signal type for this tuner	if (validSignalIndex == 0xFF) {	  validSignalIndex = ix;	}	      } else { // this signal type is invalid for this tuner		// so disable this menu item	enabled = false;		// check if our current signal type is invalid for this tuner	if (signalIndex == ix) {	  signalIndex = 0xFF;	}      }    }        static const char *signalwidgets[] = {      "signalpal",       "signalntsc",       "signalsecam",    };    temp = lookup_widget(VideoSourceDialog, signalwidgets[ix]);    gtk_widget_set_sensitive(temp, enabled);  }    // try to choose a valid signal type if we don't have one  if (signalIndex == 0xFF) {    if (validSignalIndex == 0xFF) {      // we're in trouble      debug_message("SetAvailableSignals: no valid signal type!");      signalIndex = 0;    } else {      signalIndex = validSignalIndex;    }        // cause the displayed value to be updated    gtk_option_menu_set_history(GTK_OPTION_MENU(signal_menu), signalIndex);    // TBD check that signal activate is called here  }}static bool SourceIsDevice(){  GtkWidget *temp;  temp = lookup_widget(VideoSourceDialog, "VideoSourceFile");  return IsDevice(gtk_entry_get_text(GTK_ENTRY(temp)));}static void EnableChannels(){	bool hasTuner = false;	uint inputIndex;	GtkWidget *temp;	temp = lookup_widget(VideoSourceDialog, "VideoSourcePort");	inputIndex = gtk_option_menu_get_history(GTK_OPTION_MENU(temp));	if (pVideoCaps && pVideoCaps->m_inputHasTuners[inputIndex]) {		hasTuner = true;	}		temp = lookup_widget(VideoSourceDialog, 			     "VideoSourceChannelType");	gtk_widget_set_sensitive(temp, hasTuner);	temp = lookup_widget(VideoSourceDialog,			     "VideoSourceChannel");	gtk_widget_set_sensitive(temp, hasTuner);}static void ChangeInput (void){	SetAvailableSignals();	EnableChannels();}static void on_input_menu_activate(GtkOptionMenu *menu, gpointer data){  ChangeInput();}void CreateInputMenu(CVideoCapabilities* pNewVideoCaps,		     uint inputIndex){  u_int8_t newInputNumber;  if (pNewVideoCaps) {    newInputNumber = pNewVideoCaps->m_numInputs;  } else {    newInputNumber = 0;  }    if (inputIndex >= newInputNumber) {    inputIndex = 0;   }  // create new menu item names  const char** newInputNames = (const char**)malloc(sizeof(char*) * newInputNumber);  for (u_int8_t i = 0; i < newInputNumber; i++) {    char buf[64];    snprintf(buf, sizeof(buf), "%u - %s",	     i, pNewVideoCaps->m_inputNames[i]);    newInputNames[i] = strdup(buf);  }  // (re)create the menu  GtkWidget *temp = lookup_widget(VideoSourceDialog, "VideoSourcePort");  CreateOptionMenu(		   temp,		   newInputNames, 		   newInputNumber,		   inputIndex);  // free up old names  for (u_int8_t i = 0; i < inputNumber; i++) {    free((void *)inputNames[i]);  }  free(inputNames);  inputNames = newInputNames;  inputNumber = newInputNumber;}static void SourceV4LDevice(){  GtkWidget *temp;  temp = lookup_widget(VideoSourceDialog, "VideoSourceFile");  const char *newSourceName =    gtk_entry_get_text(GTK_ENTRY(temp));  // don't probe the already open device!  if (!strcmp(newSourceName, 	      MyConfig->GetStringValue(CONFIG_VIDEO_SOURCE_NAME))) {    return;  }

⌨️ 快捷键说明

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