Mercurial > hg > Applications > TreeVNC
changeset 296:966331aef4b3
add share sound dialog when screen change request.
author | oc |
---|---|
date | Thu, 15 Jan 2015 03:18:13 +0900 |
parents | 71d24f7b3b3b |
children | ba5ab113fcca |
files | src/main/java/jp/ac/u_ryukyu/treevnc/ReceiveSound.java src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionView.java |
diffstat | 4 files changed, 44 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/ReceiveSound.java Tue Jan 13 15:08:53 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/ReceiveSound.java Thu Jan 15 03:18:13 2015 +0900 @@ -45,6 +45,7 @@ while(!isStop) { try { this.socket.receive(packet); + System.out.println(packet); // skip rtp header. byteArrayInputStream = new ByteArrayInputStream(packet.getData(), 12, 160); ulawStream = new AudioInputStream(byteArrayInputStream, ulawFormat, 160);
--- a/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Tue Jan 13 15:08:53 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/ConnectionPresenter.java Thu Jan 15 03:18:13 2015 +0900 @@ -208,6 +208,15 @@ } } + public boolean showShareSoundDialog() { + final ConnectionView connectionView = (ConnectionView) getView(CONNECTION_VIEW); + boolean shareSound = false; + if (connectionView != null) { + shareSound = connectionView.showShareSoundDialog(); + } + return shareSound; + } + private void setSshOptions() { if (hasSshSupport) { try {
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Tue Jan 13 15:08:53 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/SwingViewerWindow.java Thu Jan 15 03:18:13 2015 +0900 @@ -35,6 +35,7 @@ import com.glavsoft.viewer.UiSettings; import com.glavsoft.viewer.Viewer; import com.glavsoft.viewer.ViewerInterface; +import com.glavsoft.viewer.swing.gui.ConnectionView; import com.glavsoft.viewer.swing.gui.OptionsDialog; import javax.swing.*; @@ -854,6 +855,16 @@ int rightScreenNumber = 1; viewer.getRfb().singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); + // show share sound dialog. + boolean setShareSound = presenter.showShareSoundDialog(); + if (setShareSound) try { + shareSound(viewer.getRfb().isTreeManager(), context); + } catch (SocketException e1) { + e1.printStackTrace(); + } catch (UnknownHostException e1) { + e1.printStackTrace(); + } + if (viewer.getRfb().isTreeManager()) { changeVncServer(viewer, (int) rectangles.get(leftScreenNumber).getWidth(), (int) rectangles.get(leftScreenNumber).getHeight(), viewer.getRfb().getId()); return; @@ -867,30 +878,7 @@ final JButton soundButton = buttonsBar.createButton("share-screen-sound", "Share Screen and Sound", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - - Dimension size = frame.getSize(); - viewer.setFrameSize(size.width, size.height); - - ArrayList<Rectangle> rectangles = getScreenRectangles(); - int leftScreenNumber = 0; - int rightScreenNumber = 1; - viewer.getRfb().singleWidth = (int) rectangles.get(leftScreenNumber).getWidth(); - - try { - if (viewer.getRfb().isTreeManager()) { - changeVncServer(viewer, (int) rectangles.get(leftScreenNumber).getWidth(), (int) rectangles.get(leftScreenNumber).getHeight(), viewer.getRfb().getId()); - viewer.getRfb().createShareSoundThread(viewer.getRfb()); - return; - } - String adr = viewer.getRfb().getMyAddress(); - context.sendMessage(new ScreenChangeRequest(adr, viewer.getRfb().getId(), (int) rectangles.get(leftScreenNumber).getWidth(), (int) rectangles.get(leftScreenNumber).getHeight())); - context.sendMessage(new ReadyShareSound()); - viewer.getRfb().createShareSoundThread(viewer.getRfb()); - } catch (SocketException e1) { - e1.printStackTrace(); - } catch (UnknownHostException e1) { - e1.printStackTrace(); - } + // 再生するかどうかボタンにしよう } }); kbdButtons.add(soundButton); @@ -938,6 +926,13 @@ setButtonsBarVisible(true, container); } + private void shareSound(boolean isTreeManager, ProtocolContext context) throws SocketException, UnknownHostException { + if (isTreeManager) { + viewer.getRfb().createShareSoundThread(viewer.getRfb()); + } + context.sendMessage(new ReadyShareSound()); + } + private void sendCtrlAltDel(ProtocolContext context) { context.sendMessage(new KeyEventMessage(Keymap.K_CTRL_LEFT, true)); context.sendMessage(new KeyEventMessage(Keymap.K_ALT_LEFT, true)); @@ -1013,8 +1008,9 @@ // before change server, data from previous server // should be stopped. viewer.setCuiVersion(false); - // Host have screens in rectangles. + // Host have screens. // Each screen number in order from left. + // put screens in rectangles. ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); GraphicsConfiguration[] gc = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
--- a/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionView.java Tue Jan 13 15:08:53 2015 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/swing/gui/ConnectionView.java Thu Jan 15 03:18:13 2015 +0900 @@ -157,6 +157,19 @@ } } + public boolean showShareSoundDialog() { + JOptionPane shareSoundPane = new JOptionPane("Share sound?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); + final String title = "share sound"; + final JDialog shareSoundPaneDialog = shareSoundPane.createDialog(ConnectionView.this, title); + Utils.decorateDialog(shareSoundPaneDialog); + shareSoundPaneDialog.setVisible(true); + boolean shareSound = false; + if ((Integer)shareSoundPane.getValue() == JOptionPane.YES_OPTION) { + shareSound = true; + } + return shareSound; + } + public void setConnectionInProgress(boolean enable) { if (enable) { connectionInProgress = true;