-
Notifications
You must be signed in to change notification settings - Fork 0
/
VideoEndpoint.java
43 lines (34 loc) · 1.11 KB
/
VideoEndpoint.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
package com.example.videobackend.video_backend_example;
import com.zandero.rest.annotation.RequestReader;
import javax.ws.rs.*;
@Path("video")
public class VideoEndpoint {
private VideoObject videoObject;
@GET()
@Produces("application/json")
public ActionStatus checkHealth() {
return ActionStatus.ok();
}
@POST()
@Path("/init")
@Produces("application/json")
public ActionStatus initVideoProject() {
videoObject = new VideoObject();
if(videoObject.initVideoObject("C:\\Users\\Deven.Yantis\\Documents\\example_videos\\vid2.mp4")) {
return ActionStatus.ok();
}
return ActionStatus.failedWithMessage("Fail to init video");
}
@GET()
@Path("frame/{frameIdx}")
@Produces("application/json")
public VideoResponseStatus extractFrame(
@PathParam("frameIdx") int frameIdx
) {
String frame = videoObject.getBase64Frames().get(frameIdx);
if(frame == null) {
return VideoResponseStatus.failedWithMessage("Fail to get frame");
}
return VideoResponseStatus.ok(frame);
}
}