-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.java
76 lines (62 loc) · 2.65 KB
/
Server.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.headless.HeadlessMediaPlayer;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
public class Server {
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
public static void main(final String[] args) {
new NativeDiscovery().discover();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Server(args);
}
});
}
private Server(String[] args) {
JFrame frame = new JFrame("vlcj");
System.out.println(LibVlc.INSTANCE.libvlc_get_version());
mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
frame.setContentPane(mediaPlayerComponent);
//TO DO! choose the correct arguments for the methods below. Add more method calls as necessary
//frame.setLocation(...);
frame.setLocation(100, 100);//localizacion en la pantalla (su esquina izq superior).
//frame.setSize(...);
frame.setSize(800, 800);//tamaño de la ventana en la localizacion que le ponemos.
//TO DO!! configure the video delivery via RTP
String media = "file:///home/parsac/AudioVisuales/Practica_AudioVisuales/movie.mp4";
String options = formatRtpStream("127.0.0.1", 5004);
System.out.println("Streaming '" + media + "' to '" + options + "'");
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(args);//cambiado
HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
System.out.println("Media playing ->" +
mediaPlayer.playMedia(media,
options,
":no-sout-rtp-sap",
":no-sout-standard-sap",
":sout-all",
":sout-keep")
);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
//
}
private static String formatRtpStream(String serverAddress, int serverPort) {
StringBuilder sb = new StringBuilder(60);
sb.append(":sout=#rtp{dst=");
sb.append(serverAddress);
sb.append(",port=");
sb.append(serverPort);
sb.append(",mux=ts}");
return sb.toString();
}
}