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

📄 gui_main.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  GLADE_HOOKUP_OBJECT_NO_REF(DeleteStreamDialog, dialog_vbox2, "dialog_vbox2");  GLADE_HOOKUP_OBJECT(DeleteStreamDialog, vbox21, "vbox21");  GLADE_HOOKUP_OBJECT(DeleteStreamDialog, label72, "label72");  GLADE_HOOKUP_OBJECT(DeleteStreamDialog, DeleteStreamLabel, "DeleteStreamLabel");  GLADE_HOOKUP_OBJECT(DeleteStreamDialog, label74, "label74");  GLADE_HOOKUP_OBJECT_NO_REF(DeleteStreamDialog, dialog_action_area2, "dialog_action_area2");  GLADE_HOOKUP_OBJECT(DeleteStreamDialog, cancelbutton2, "cancelbutton2");  GLADE_HOOKUP_OBJECT(DeleteStreamDialog, DeleteStreamButton, "DeleteStreamButton");  gtk_widget_grab_focus(cancelbutton2);  gtk_widget_show(DeleteStreamDialog);}// When the transmit enabled gets clickedstatic voidon_StreamTransmit_toggled              (GtkToggleButton *togglebutton,                                        gpointer         user_data){  if (started) return;  bool set = gtk_toggle_button_get_active(togglebutton);  CMediaStream *ms = GetSelectedStream();  if (ms == NULL) return;  ms->SetBoolValue(STREAM_TRANSMIT, set);  DisplayStreamData(SelectedStream);}// When the record gets clickedstatic voidon_StreamRecord_toggled                (GtkToggleButton *togglebutton,                                        gpointer         user_data){  if (started) return;  bool set = gtk_toggle_button_get_active(togglebutton);  CMediaStream *ms = GetSelectedStream();  if (ms == NULL) return;  ms->SetBoolValue(STREAM_RECORD, set);  DisplayStreamRecord(ms);}// List of files, their stream configuration indexesstatic const struct {  config_index_t *pConfigIndex;  const char *header;  const char *widget;} FileOpenIndexes[] = {  { &STREAM_RECORD_MP4_FILE_NAME,    "MP4 File Name",    "StreamRecordFileEntry" },  { &STREAM_SDP_FILE_NAME,    "Select Stream SDP Output File",    "StreamSdpFileEntry"},};// The return from the browse button for SDP or mp4 file. static void onFileOpenResponse (GtkDialog *sel,				gint response_id,				gpointer user_data){  if (GTK_RESPONSE_OK == response_id) {    CMediaStream *ms = GetSelectedStream();    uint index = GPOINTER_TO_INT(user_data);    const char *name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sel));    ms->SetStringValue(*FileOpenIndexes[index].pConfigIndex,		       name);    GtkWidget *wid = lookup_widget(MainWindow, 				   FileOpenIndexes[index].widget);    gtk_entry_set_text(GTK_ENTRY(wid), name);  }  gtk_widget_destroy(GTK_WIDGET(sel));}// create the file selection dialog for SDP file or mp4 file.static voidon_FileOpenButton_clicked        (GtkButton       *button,				  gpointer         user_data){  uint index = GPOINTER_TO_INT(user_data);  GtkWidget *FileSelection;  GtkWidget *FileOkayButton;  GtkWidget *cancel_button1;  FileSelection =     gtk_file_selection_new(FileOpenIndexes[index].header);  gtk_container_set_border_width(GTK_CONTAINER (FileSelection), 10);  gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION (FileSelection));  CMediaStream *ms = GetSelectedStream();  gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSelection),				  ms->GetStringValue(*FileOpenIndexes[index].pConfigIndex));  FileOkayButton = GTK_FILE_SELECTION (FileSelection)->ok_button;  gtk_widget_show(FileOkayButton);  GTK_WIDGET_SET_FLAGS(FileOkayButton, GTK_CAN_DEFAULT);  cancel_button1 = GTK_FILE_SELECTION(FileSelection)->cancel_button;  gtk_widget_show(cancel_button1);  GTK_WIDGET_SET_FLAGS(cancel_button1, GTK_CAN_DEFAULT);   gtk_window_set_modal(GTK_WINDOW(FileSelection), true);  gtk_window_set_transient_for(GTK_WINDOW(FileSelection), 			       GTK_WINDOW(MainWindow));  g_signal_connect((gpointer) FileSelection, "response",		   G_CALLBACK (onFileOpenResponse),		   user_data);  gtk_widget_show(FileSelection);}// Stream video settings handlersstatic voidon_VideoEnabled_toggled                (GtkToggleButton *togglebutton,                                        gpointer         user_data){  if (started)     return;    CMediaStream *ms = GetSelectedStream();  if (ms == NULL) return;  ms->SetBoolValue(STREAM_VIDEO_ENABLED, 		   gtk_toggle_button_get_active(togglebutton));  ms->Initialize();  AVFlow->ValidateAndUpdateStreams();  DisplayStreamData(SelectedStream);}static voidon_VideoProfile_changed                (GtkOptionMenu   *optionmenu,                                        gpointer         user_data){  if (started) {    DisplayStreamData(SelectedStream);    return;  }  if (video_profile_names != NULL) {    CMediaStream *ms = GetSelectedStream();    if (ms == NULL) return;    const char *new_profile =       video_profile_names[gtk_option_menu_get_history(optionmenu)];    if (strcmp(new_profile, add_profile_string) == 0) {      CreateVideoProfileDialog(NULL);    } else if (strcmp(new_profile, customize_profile_string) == 0) {      CreateVideoProfileDialog(ms->GetVideoProfile());    } else if (strcmp(new_profile, 		      ms->GetStringValue(STREAM_VIDEO_PROFILE)) != 0) {      ms->SetVideoProfile(new_profile);      AVFlow->ValidateAndUpdateStreams();      MainWindowDisplaySources();      if (MyConfig->GetBoolValue(CONFIG_VIDEO_PREVIEW)) {	AVFlow->StartVideoPreview();      }      DisplayStreamData(SelectedStream);    }  }}// inpreview is required, because calling DisplayStreamData may cause// other signals to be emited, calling this more than 1 timestatic bool inpreview = false;static voidon_VideoPreview                        (GtkToggleButton *togglebutton,                                        gpointer         user_data){  if (inpreview) return;  inpreview = true;  int type = GPOINTER_TO_INT(user_data);  int raw_toggled = (GPOINTER_TO_INT(user_data) == 0);  GtkWidget *raw, *stream;  raw = lookup_widget(MainWindow, "VideoSourcePreview");  stream = lookup_widget(MainWindow, "StreamVideoPreview");  bool raw_set, stream_set;  const char *stream_name;  raw_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(raw));  stream_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stream));  if (type == 2 || (raw_set == false && stream_set == false)) {    if (type != 2 && MyConfig->GetBoolValue(CONFIG_VIDEO_PREVIEW)) {      stream_name = MyConfig->GetStringValue(CONFIG_VIDEO_PREVIEW_STREAM);      if (raw_toggled == false &&	  stream_name && strcmp(stream_name, SelectedStream) != 0) {	// we're turning off for this preview	inpreview = false;	return;      }          }    if (raw_set)       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(raw), false);    if (stream_set)       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stream), false);    MyConfig->SetBoolValue(CONFIG_VIDEO_PREVIEW, false);    AVFlow->StopVideoPreview();  } else {    // one or the other is on    if (raw_set == stream_set) {      // both are on - figure from userdata      if (raw_toggled) {	// we want raw	stream_set = false;	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stream), false);      } else {	raw_set = false;	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(raw), false);      }    }        if (MyConfig->GetBoolValue(CONFIG_VIDEO_PREVIEW) == true) {      if (raw_set && raw_toggled == false) {	if (MyConfig->GetStringValue(CONFIG_VIDEO_PREVIEW_STREAM) == NULL) 	  inpreview = false;	  return;      } else {	stream_name = MyConfig->GetStringValue(CONFIG_VIDEO_PREVIEW_STREAM);	if (raw_toggled == false &&	    stream_name && strcmp(stream_name, SelectedStream) == 0) {	  inpreview = false;	  return;	}      }    }    MyConfig->SetBoolValue(CONFIG_VIDEO_PREVIEW, true);    MyConfig->SetStringValue(CONFIG_VIDEO_PREVIEW_STREAM,			     raw_set  ? NULL : SelectedStream);    AVFlow->StartVideoPreview();    if (started == false) {	status_timer_id = gtk_timeout_add(1000, status_timer, MainWindow);    }  }  inpreview = false;}static voidon_VideoTxAddrButton_clicked           (GtkButton       *button,                                        gpointer         user_data){  create_IpAddrDialog(GetSelectedStream(), false, true, false);}// Stream audio settings handlersstatic voidon_AudioEnabled_toggled                (GtkToggleButton *togglebutton,                                        gpointer         user_data){  CMediaStream *ms = GetSelectedStream();  if (ms == NULL) return;  ms->SetBoolValue(STREAM_AUDIO_ENABLED, 		   gtk_toggle_button_get_active(togglebutton));  ms->Initialize();  AVFlow->ValidateAndUpdateStreams();  DisplayStreamData(SelectedStream);}static voidon_AudioProfile_changed                (GtkOptionMenu   *optionmenu,                                        gpointer         user_data){  if (started) {    DisplayStreamData(SelectedStream);    return;  }  if (audio_profile_names != NULL) {    CMediaStream *ms = GetSelectedStream();    if (ms == NULL) return;    const char *new_profile =       audio_profile_names[gtk_option_menu_get_history(optionmenu)];    if (strcmp(new_profile, add_profile_string) == 0) {      CreateAudioProfileDialog(NULL);    } else if (strcmp(new_profile, customize_profile_string) == 0) {      CreateAudioProfileDialog(ms->GetAudioProfile());    } else if (strcmp(new_profile, 		      ms->GetStringValue(STREAM_AUDIO_PROFILE)) != 0) {      ms->SetAudioProfile(new_profile);      AVFlow->ValidateAndUpdateStreams();      MainWindowDisplaySources();      DisplayStreamData(SelectedStream);    }  }}static voidon_AudioTxAddrButton_clicked           (GtkButton       *button,                                        gpointer         user_data){  create_IpAddrDialog(GetSelectedStream(), true, false, false);}#ifdef HAVE_TEXTstatic voidon_TextEnabled_toggled                 (GtkToggleButton *togglebutton,                                        gpointer         user_data){  CMediaStream *ms = GetSelectedStream();  if (ms == NULL) return;  ms->SetBoolValue(STREAM_TEXT_ENABLED, 		   gtk_toggle_button_get_active(togglebutton));  ms->Initialize();  AVFlow->ValidateAndUpdateStreams();  DisplayStreamData(SelectedStream);}static voidon_TextProfile_changed                 (GtkOptionMenu   *optionmenu,                                        gpointer         user_data){  if (started) {    DisplayStreamData(SelectedStream);    return;  }  if (text_profile_names != NULL) {    CMediaStream *ms = GetSelectedStream();    if (ms == NULL) return;    const char *new_profile =       text_profile_names[gtk_option_menu_get_history(optionmenu)];    if (strcmp(new_profile, add_profile_string) == 0) {      create_TextProfileDialog(NULL);    } else if (strcmp(new_profile, customize_profile_string) == 0) {      create_TextProfileDialog(ms->GetTextProfile());    } else if (strcmp(new_profile, 		      ms->GetStringValue(STREAM_TEXT_PROFILE)) != 0) {      ms->SetTextProfile(new_profile);      AVFlow->ValidateAndUpdateStreams();      MainWindowDisplaySources();      DisplayStreamData(SelectedStream);    }  }}static voidon_TextTxAddrButton_clicked            (GtkButton       *button,                                        gpointer         user_data){  create_IpAddrDialog(GetSelectedStream(), false, false, true);}#ifdef HAVE_TEXT_ENTRYstatic voidon_TextEntrySend_clicked               (GtkButton       *button,                                        gpointer         user_data){}#endif#endif// If they change the duration.  Don't know why we care.static voidon_durationtype_activate               (GtkOptionMenu     *menu,                                        gpointer         user_data){  MyConfig->SetIntegerValue(CONFIG_APP_DURATION_UNITS, 			    durationUnitsValues[gtk_option_menu_get_history(menu)]);}void DoStart(){  GtkWidget *temp;  ReadConfigFromWindow();    if (!MyConfig->GetBoolValue(CONFIG_AUDIO_ENABLE)      && !MyConfig->GetBoolValue(CONFIG_VIDEO_ENABLE)       && !MyConfig->GetBoolValue(CONFIG_TEXT_ENABLE)) {    ShowMessage("No Media", "Neither audio nor video are enabled", MainWindow);    return;  }    // lock out change to settings while media is running  LockoutChanges(true);  GtkWidget *statusbar = lookup_widget(MainWindow, "statusbar1");  gtk_statusbar_pop(GTK_STATUSBAR(statusbar), 0);  gtk_statusbar_push(GTK_STATUSBAR(statusbar), 		     0,		     "Starting");    AVFlow->Start();  gtk_statusbar_pop(GTK_STATUSBAR(statusbar), 0);  gtk_statusbar_push(GTK_STATUSBAR(statusbar), 		     0,		     "Started");  if (MyConfig->GetBoolValue(CONFIG_TEXT_ENABLE)) {    const char *type = MyConfig->GetStringValue(CONFIG_TEXT_SOURCE_TYPE);        bool have_file;    have_file = strcmp(type, TEXT_SOURCE_FILE_WITH_DIALOG) == 0;    if (have_file || strcmp(type, TEXT_SOURCE_DIALOG) == 0) {      GtkWidget *textd = create_TextFileDialog(have_file);      GLADE_HOOKUP_OBJECT(MainWindow, textd, "TextDialog");    }  }    StartTime = GetTimestamp(); #if 0  if (MyConfig->GetBoolValue(CONFIG_VIDEO_ENABLE)) {    if (MyConfig->IsCaptureVideoSource()) {      AVFlow->GetStatus(FLOW_STATUS_VIDEO_ENCODED_FRAMES, 			&StartEncodedFrameNumber);    } else {      StartEncodedFrameNumber = 0;    }  }#endif  FlowDuration =    MyConfig->GetIntegerValue(CONFIG_APP_DURATION) *    MyConfig->GetIntegerValue(CONFIG_APP_DURATION_UNITS) *     TimestampTicks;  debug_message(U64" %u dur %u units",		FlowDuration, 		MyConfig->GetIntegerValue(CONFIG_APP_DURATION),		MyConfig->GetIntegerValue(CONFIG_APP_DURATION_UNITS)); 		

⌨️ 快捷键说明

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