• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WindhoverLabs / yamcs-cfs / #164

11 Dec 2024 11:11PM UTC coverage: 0.0%. Remained the same
#164

push

lorenzo-gomez-windhover
-Add Execute method to pipeline.

0 of 63 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 8527 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/windhoverlabs/com/video/Pipeline.java
1
package com.windhoverlabs.com.video;
2

3
import static org.bytedeco.ffmpeg.global.avutil.*;
4

5
import org.bytedeco.ffmpeg.avcodec.AVPacket;
6
import org.bytedeco.ffmpeg.avformat.AVStream;
7
import org.bytedeco.ffmpeg.avutil.*;
8
import org.bytedeco.ffmpeg.global.avcodec;
9

10
public class Pipeline extends ComponentBase {
11

12
  private MMC_PipelineCfg config;
13
  private AVBufferRef hwAccelDeviceContext;
14
  //  TODO:It might make more sense to change these arrays to ArrayList(s)
15
  private InputPipeline[] inputPipelines = new InputPipeline[MAX_INPUT_PIPELINES];
×
16
  private FilterGraph filterGraph = new FilterGraph();
×
17
  private OutputPipeline[] outputPipelines = new OutputPipeline[MAX_OUTPUT_PIPELINES];
×
18

NEW
19
  private int ChannelID = 0xFFFFFFFF;
×
20
  private TState State;
21
  private AVFrame Frame;
22
  private AVPacket Packet;
23

UNCOV
24
  public Pipeline() {
×
25
    // TODO: Auto-generated constructor stub
26
  }
×
27

28
  @Override
29
  protected void finalize() throws Throwable {
30
    // TODO: Auto-generated destructor stub
31
    super.finalize();
×
32
  }
×
33

34
  public EReturnCode setConfig(MMC_PipelineCfg config) {
35
    EReturnCode rc = EReturnCode.OK;
×
36

37
    this.config = config;
×
38

39
    for (int i = 0; i < MAX_INPUT_PIPELINES; i++) {
×
40
      inputPipelines[i] = new InputPipeline();
×
41
      inputPipelines[i].SetConfig(config.InputPipelineCfg.get(i));
×
42
    }
43

44
    filterGraph.SetConfig(config.FilterGraphCfg);
×
45

46
    for (int i = 0; i < MAX_OUTPUT_PIPELINES; i++) {
×
47
      outputPipelines[i] = new OutputPipeline();
×
48
      outputPipelines[i].setConfig(config.OutputPipelineCfg.get(i));
×
49
    }
50

51
    return rc;
×
52
  }
53

54
  public void initializeHWAccel() {
55
    int avRC =
×
56
        av_hwdevice_ctx_create(
×
57
            hwAccelDeviceContext,
58
            config.HWAccelDeviceCfg.deviceType,
59
            config.HWAccelDeviceCfg.deviceID,
60
            null,
61
            0);
62

63
    if (avRC < 0) {
×
NEW
64
      ReportAVError(
×
65
          "CPipeline::InitializeHardware",
66
          "av_hwdevice_ctx_create",
67
          avRC,
NEW
68
          Thread.currentThread().getStackTrace()[0].getLineNumber());
×
69
    }
70
  }
×
71

72
  public EReturnCode Initialize() {
NEW
73
    EReturnCode rc = EReturnCode.OK;
×
74

NEW
75
    super.Initialize();
×
76

NEW
77
    Frame = av_frame_alloc();
×
NEW
78
    Packet = avcodec.av_packet_alloc();
×
79

80
    // First set the pipeline IDs, so error reporting will be correct.
NEW
81
    for (int i = 0; i < MAX_INPUT_PIPELINES; i++) {
×
NEW
82
      inputPipelines[i].SetPipelineID(i);
×
83
    }
84

NEW
85
    for (int i = 0; i < MAX_OUTPUT_PIPELINES; i++) {
×
NEW
86
      outputPipelines[i].SetPipelineID(i);
×
87
    }
88

NEW
89
    initializeHWAccel();
×
90

NEW
91
    if (!config.PacketLevelRemux) {
×
NEW
92
      FilterGraph.Initialize();
×
93
    }
94

95
    // Now initialize the pipelines.
NEW
96
    for (int i = 0; i < MAX_INPUT_PIPELINES; i++) {
×
NEW
97
      inputPipelines[i].Initialize(filterGraph, hwAccelDeviceContext);
×
98
    }
99

NEW
100
    for (int i = 0; i < MAX_OUTPUT_PIPELINES; i++) {
×
NEW
101
      AVStream inputStream = inputPipelines[i].GetStream();
×
102

NEW
103
      outputPipelines[i].Initialize(
×
104
          config.PacketLevelRemux, filterGraph, hwAccelDeviceContext, inputStream);
105
    }
106

NEW
107
    if (!config.PacketLevelRemux) {
×
NEW
108
      FilterGraph.Start();
×
NEW
109
      if (rc != EReturnCode.OK) {
×
NEW
110
        rc = EReturnCode.FAILED_INITIALIZATION;
×
NEW
111
        return rc;
×
112
      }
113
    }
114

NEW
115
    State = TState.ACTIVE;
×
116

NEW
117
    return rc;
×
118
  }
119

120
  public TState GetState() {
NEW
121
    return State;
×
122
  }
123

124
  EReturnCode Restart(int PipelineID) {
NEW
125
    EReturnCode rc = EReturnCode.OK;
×
126

NEW
127
    rc = inputPipelines[PipelineID].Restart();
×
128

NEW
129
    if (EReturnCode.OK == rc) {
×
NEW
130
      rc = outputPipelines[PipelineID].restart();
×
131
    }
132

NEW
133
    return rc;
×
134
  }
135

136
  EReturnCode Execute() {
NEW
137
    EReturnCode rc = EReturnCode.OK;
×
138

NEW
139
    if (TState.ACTIVE == State) {
×
NEW
140
      for (int i = 0; i < MAX_INPUT_PIPELINES; ++i) {
×
NEW
141
        if (config.PacketLevelRemux) {
×
142

NEW
143
          rc = inputPipelines[i].ReadPacket(Packet);
×
NEW
144
          if (EReturnCode.OK_EOF == rc) {
×
NEW
145
            Restart(i);
×
NEW
146
            continue;
×
147
          }
148

NEW
149
          if (rc != EReturnCode.OK) {
×
150
            /* TODO */
NEW
151
            State = TState.INACTIVE;
×
152
            //                                        goto end_of_function;
153
          }
154

NEW
155
          rc = outputPipelines[i].SendPacket(Packet);
×
NEW
156
          if (rc != EReturnCode.OK) {
×
157
            /* TODO */
NEW
158
            State = TState.INACTIVE;
×
159
            //                                        goto end_of_function;
160
          }
161
        } else {
NEW
162
          rc = inputPipelines[i].ReadFrame();
×
NEW
163
          if (EReturnCode.OK_EOF == rc) {
×
NEW
164
            Restart(i);
×
NEW
165
          } else if (rc != EReturnCode.OK) {
×
166
            /* TODO */
NEW
167
            State = TState.INACTIVE;
×
168
            //                                        goto end_of_function;
169
          }
170

NEW
171
          rc = outputPipelines[i].SendFrame();
×
NEW
172
          while (rc == EReturnCode.OK_QUEUE_EMPTY) {
×
NEW
173
            rc = outputPipelines[i].SendFrame();
×
174
          }
NEW
175
          if (rc != EReturnCode.OK) {
×
176
            /* TODO */
NEW
177
            State = TState.INACTIVE;
×
178
            //                                        goto end_of_function;
179
          }
180
        }
181

182
        //                        filterGraph.SetFrame(i, inputPipelines[i].GetFrame());
183
      }
184

185
      //                filterGraph.Execute();
186
      //
187
      //                for(int i = 0; i < MAX_OUTPUT_PIPELINES; ++i)
188
      //                {
189
      //                        OutputPipeline[i].SetFrame(FilterGraph.GetFrame(i));
190
      //                        OutputPipeline[i].Execute();
191
      //                }
192
    }
193

194
    // end_of_function:
195

NEW
196
    return rc;
×
197
  }
198

199
  // Constants (replace with actual values)
200
  private static final int MAX_INPUT_PIPELINES = 4;
201
  private static final int MAX_OUTPUT_PIPELINES = 4;
202
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc