📄 embeddedapp.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: embeddedapp.cpp,v 1.39.2.16 2004/12/07 21:17:19 nhart Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** */#include "appver.h"#include "embeddedapp.h"#include "commonapp.h"#include "playeripc.h"#include "hxbin.h"#include "contextmenu.h"#include "hxplayer-i18n.h"#include "hxgvalue.h"#include "hxgprefs.h"#include "about.h"#include "prefsdialog.h"#include "statistics.h"/* Status widgets */#include "hxstatusfield.h"#include "hxstatusinfopanel.h"#include "hxstatuspositionfield.h"#include "hxstatuspositionslider.h"#include "hxstatustacctrl.h"#include "hxstatuscongestion.h"#include "embddef.h"#include <string.h>#include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <stdlib.h>#include <glib.h>/* This file contains functions with several different prefixes. * They include: * hxembedded_window - operate on HXEmbeddedWindow objects. A * HXEmbeddedWindow object represents a * single <embed> tag in an html page. It * could be an image window, button, status * bar, etc. * * hxembedded_player - This is a collection of HXEmbeddedWindow * that, together, define a player. * * hxembedded_console - This is a collection of players, and a * set of control "windows" that together * define a console. * * hew - For (h)xplayer (e)mbedded (w)idget, these functions are * designed to work as callbacks to the hx_player_widget. * * no prefix - These functions are "private" supporting functions for * one of the methods above, and are not intended for general * use * *//* Constants: * ========== */#define FF_RW_UPDATE_PERIOD 100 // ms = 0.5 seconds#define HX_CALLBACK_KEY_EVENTS ((HXCallbackFlags) \ (HX_CALLBACK_ON_KEY_DOWN | \ HX_CALLBACK_ON_KEY_PRESS | \ HX_CALLBACK_ON_KEY_UP))#define HX_CALLBACK_MOUSE_EVENTS ((HXCallbackFlags) \ (HX_CALLBACK_ON_MOUSE_MOVE | \ HX_CALLBACK_ON_LBUTTON_UP | \ HX_CALLBACK_ON_LBUTTON_DOWN | \ HX_CALLBACK_ON_RBUTTON_UP | \ HX_CALLBACK_ON_RBUTTON_DOWN))#define HX_CALLBACK_ERROR_EVENTS ((HXCallbackFlags) \ (HX_CALLBACK_ON_ERROR_MESSAGE)) #define POS_LEN_CALLBACK_INTERVAL 1000 /* ms -- once a second *//* Forward Declarations: * ===================== */extern "C"{/* Commands for the context menu (similar to hmw_* in hxplayer.h) */void hew_play(GtkWidget* widget);void hew_stop(GtkWidget* widget);void hew_pause(GtkWidget* widget);void hew_mute(GtkWidget* widget);void hew_volume_changed(GtkWidget* widget);gboolean hew_ff_start(HXEmbeddedWindow* window, GdkEventButton* event);gboolean hew_ff(gpointer data);gboolean hew_ff_stop(HXEmbeddedWindow* window, GdkEventButton* event);gboolean hew_rewind_start(HXEmbeddedWindow* window, GdkEventButton* event);gboolean hew_rewind(gpointer data);gboolean hew_rewind_stop(HXEmbeddedWindow* window, GdkEventButton* event);/* Callbacks for the embedded widget (similar to hpw in hxwindow.cpp) */void hepw_mute_changed(HXEmbeddedWindow* window, gboolean mute);void hepw_play_buffer_contact(HXEmbeddedWindow* window);void hepw_pause(HXEmbeddedWindow* window);void hepw_stop(HXEmbeddedWindow* window);void hepw_volume_changed(HXEmbeddedWindow* window, guint vol);void hepw_error(HXEmbeddedWindow* window, GError* error);void hepw_hxerror(HXEmbeddedWindow* window, guint hxcode, guint user_code, const gchar* error_string, const gchar* user_string, const gchar* more_info_url);void hepw_request_upgrade(HXEmbeddedWindow* window, const gchar* url, GList* components_list, gboolean blocking, gpointer);void hepw_request_authentication(HXEmbeddedWindow* window, const gchar* server_proxy, const gchar* realm, gboolean is_proxy_server);void hepw_open_window(HXEmbeddedWindow* window, gchar* url, gchar* target);void hepw_goto_url(HXEmbeddedWindow* window, gchar* url, gchar* target);void hepw_start_seeking(HXEmbeddedWindow* window);void hepw_stop_seeking(HXEmbeddedWindow* window);};void hxembedded_window_hookup_ipc_callbacks(HXEmbeddedWindow* window);void hxembedded_window_show_volume_popup (HXEmbeddedWindow* window, GtkWidget* widget);void hxembedded_window_volume_changed (HXEmbeddedWindow* window);/* Data structures * =============== */// Signal-based callbacks that are per-HXEmbeddedWindowtypedef struct{ gboolean is_enabled; gulong id;} HXWindowSigInfo;// Signal-based callbacks that are per-HXEmbeddedPlayertypedef struct{ gboolean is_enabled; GObject* target; gulong id;} HXPlayerSigInfo;// Non-signal-based callbacks that are per-HXEmbeddedPlayertypedef struct{ gboolean is_enabled;} HXPlayerCallbackInfo;struct _HXEmbeddedConsole;typedef struct _HXEmbeddedConsole HXEmbeddedConsole;typedef struct{ HXPlayer* player; HXBin* hxbin; HXContextMenu* context_menu;} HXEmbeddedWindowImageWindow;typedef struct{ GtkWidget* button; GtkWidget* image; GdkPixbuf* mute_pixbuf; GdkPixbuf* off_pixbuf; GdkPixbuf* low_pixbuf; GdkPixbuf* mid_pixbuf; GdkPixbuf* high_pixbuf;} HXEmbeddedWindowMuteCtrl;typedef struct{ GtkWidget* scale;} HXEmbeddedWindowVolumeSlider;typedef struct{ GtkWidget* button; GtkWidget* image; GdkPixbuf* play_pixbuf; GdkPixbuf* pause_pixbuf;} HXEmbeddedWindowPlayPauseButton;typedef struct{ GtkWidget* button;} HXEmbeddedWindowPlayButton;typedef struct{ GtkWidget* button;} HXEmbeddedWindowPauseButton;typedef struct{ GtkWidget* button;} HXEmbeddedWindowStopButton;typedef struct{ GtkWidget* button; gint timer_id;} HXEmbeddedWindowFastForwardButton;typedef struct{ GtkWidget* button; gint timer_id;} HXEmbeddedWindowRewindButton;typedef struct{ GtkWidget* popup_window; GtkWidget* button; GtkWidget* image; GdkPixbuf* mute_pixbuf; GdkPixbuf* off_pixbuf; GdkPixbuf* low_pixbuf; GdkPixbuf* mid_pixbuf; GdkPixbuf* high_pixbuf;} HXEmbeddedWindowMuteVolumePopup;typedef struct{ guint stream_id; HXDataStream* stream; gchar* url; gchar* mime_type;} HXDataStreamInfo;typedef struct _HXEmbeddedWindow{ guint id; GList* streams_list; gchar* src_url; /* Qualified url of the <embed> tag, passed by NewStream */ HXEmbeddedWindowAttributes attr; gboolean is_global; /* Affects all players in the console */ GtkWidget* window; HXEmbeddedConsole* console; XID parent_xid; guint parent_socket_id; GtkWidget* widget; gboolean is_window_set; GtkWidget* alignment; /* Helix error information, for use with the JavaScript api */ guint helix_error_code; guint helix_user_code; gchar* helix_error_string; gchar* helix_user_string; gchar* helix_more_info_url; /* Attributes that can be set via javascript */ gchar* author_override; gchar* title_override; gchar* copyright_override; /* Last status message sent by the OnShowStatus callback. This is returned by GetLastStatus */ gchar* status_message; /* Show status information in the image window. Set using SetImageStatus. */ // XXXRGG: Implement this gboolean show_status_in_image_window; /* Enable/disable the context menu */ gboolean enable_context_menu; /* XXXRGG: Not sure what this is (does it disable error messagebox's?) but you can get/set it with (Set)EnableMessageBox */ gboolean enable_message_box; /* Determines whether errors go to the error callbacks, if the player should pop up a dialog */ gboolean enable_error_events; /* Various other enables/disables */ gboolean enable_original_size; gboolean enable_double_size; //XXXRGG What is DoubleSize in the context of an embedded player? gboolean enable_fullscreen; gboolean enable_seek; /* attr.controls is used to determine the type */ HXEmbeddedWindowImageWindow* image_window; HXEmbeddedWindowMuteCtrl* mute_ctrl; HXEmbeddedWindowVolumeSlider* volume_slider; HXEmbeddedWindowPlayButton* play_button; HXEmbeddedWindowPauseButton* pause_button; HXEmbeddedWindowStopButton* stop_button; HXEmbeddedWindowPlayPauseButton* play_pause_button; HXEmbeddedWindowFastForwardButton* ff_button; HXEmbeddedWindowRewindButton* rewind_button; HXEmbeddedWindowMuteVolumePopup* mute_volume_popup; HXStatusDisplayPositionSlider* position_slider; HXStatusDisplayInfoPanel* info_panel; HXStatusDisplayPositionField* position_field; HXStatusDisplayStatusField* status_field; HXStatusDisplayTACCtrl* tac_ctrl; HXStatusDisplayCongestion* congestion; GtkWidget* unknown; /* timer for driving the OnPosLength and OnPositionChanged */ gboolean pos_len_callback_timer_is_running; /* Signal handler info */ struct { HXPlayerCallbackInfo on_clip_closed; HXPlayerCallbackInfo on_clip_opened; HXPlayerCallbackInfo on_pos_length; HXPlayerCallbackInfo on_position_change; HXPlayerCallbackInfo on_post_seek; HXPlayerCallbackInfo on_pre_seek; HXPlayerCallbackInfo on_presentation_closed; HXPlayerCallbackInfo on_presentation_opened; HXPlayerSigInfo on_title_change; HXPlayerSigInfo on_author_change; HXPlayerSigInfo on_copyright_change; HXPlayerSigInfo on_prefetch_complete; HXPlayerSigInfo on_show_status; HXPlayerSigInfo on_buffering; HXPlayerSigInfo on_contacting; HXPlayerSigInfo on_error_message; HXPlayerSigInfo on_goto_url; HXPlayerSigInfo on_mute_change; HXPlayerSigInfo on_play_state_change; HXPlayerSigInfo on_state_change; HXPlayerSigInfo on_volume_change; } player_handlers; struct { HXWindowSigInfo on_key_down; HXWindowSigInfo on_key_press; HXWindowSigInfo on_key_up; HXWindowSigInfo on_lbutton_down; HXWindowSigInfo on_lbutton_up; HXWindowSigInfo on_mouse_move; HXWindowSigInfo on_rbutton_down; HXWindowSigInfo on_rbutton_up; } window_handlers; /* Dialogs that can be opened by the embedded player */ GtkDialog* about_dialog; GtkDialog* preferences_dialog; GtkDialog* statistics_dialog; gboolean is_seeking;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -