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

WindhoverLabs / yamcs-cfs / #167

12 Dec 2024 12:23AM UTC coverage: 0.0%. Remained the same
#167

push

lorenzo-gomez-windhover
-Load pipeline config. WIP.

0 of 411 new or added lines in 4 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 8703 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/OutputPipeline.java
1
package com.windhoverlabs.com.video;
2

3
import com.windhoverlabs.com.video.PipelineCfg.MMC_EntryState;
4
import com.windhoverlabs.com.video.PipelineCfg.MMC_OutputPipelineCfg_t;
5
import org.bytedeco.ffmpeg.avcodec.AVPacket;
6
import org.bytedeco.ffmpeg.avfilter.AVFilterContext;
7
import org.bytedeco.ffmpeg.avformat.AVStream;
8
import org.bytedeco.ffmpeg.avutil.AVBufferRef;
9
import org.bytedeco.ffmpeg.avutil.AVFrame;
10
import org.bytedeco.ffmpeg.global.avcodec;
11
import org.bytedeco.ffmpeg.global.avutil;
12

13
public class OutputPipeline {
14

15
  private Encoder encoder = new Encoder();
×
16
  private OutputFormat outputFormat = new OutputFormat();
×
17
  private Scale scaler = new Scale();
×
18
  private CustomFrameProcessor customFrameProcessor = new CustomFrameProcessor();
×
19

20
  MMC_OutputPipelineCfg_t config;
21
  Scale Scaler;
22
  CCustomFrameProcessor
23
      CustomFrameProcessor; // We might be able to use the YAMCS processor API instead here
24
  CCustomPacketProcessor CustomPacketProcessor;
25
  OutputFormat OutputFormat;
26
  Encoder Encoder;
27
  int ChannelID = 0xFFFFFFFF;
×
28
  int PipelineID = 0xFFFFFFFF;
×
29
  AVPacket Packet;
30
  AVPacket CustomizedPacket;
31
  AVFrame Frame;
32
  AVFrame CustomizedFrame;
33
  AVFrame ScaledFrame;
34
  FilterGraph FilterGraph;
35
  AVStream OutputStream;
36
  AVStream InputStream;
37
  String FilterBufferSinkName;
38
  AVFilterContext FilterBufferSinkContext;
39

40
  public OutputPipeline() {
×
41
    // TODO: Auto-generated constructor stub
42
  }
×
43

44
  @Override
45
  protected void finalize() throws Throwable {
46
    // TODO: Auto-generated destructor stub
47
    super.finalize();
×
48
  }
×
49

50
  public EReturnCode restart() {
51
    EReturnCode rc = EReturnCode.OK;
×
52

53
    if (config == null) {
×
54
      // TODO: Handle null configuration case
55
    } else {
NEW
56
      if (config.State == PipelineCfg.MMC_EntryState.ACTIVE) {
×
57
        encoder.reset();
×
58

59
        rc = outputFormat.Restart();
×
60
        if (rc != EReturnCode.OK) {
×
61
          return rc;
×
62
        }
63
      }
64
    }
65

66
    return rc;
×
67
  }
68

69
  public EReturnCode setConfig(MMC_OutputPipelineCfg_t inConfig) {
70
    EReturnCode rc = EReturnCode.OK;
×
71

72
    this.config = inConfig;
×
73

74
    rc = scaler.SetConfig(inConfig.ScaleCfg);
×
75
    if (rc != EReturnCode.OK) {
×
76
      // TODO: Handle scaler configuration failure
77
      return rc;
×
78
    }
79

80
    rc = customFrameProcessor.setConfig(inConfig.CustomFrameProcessorCfg);
×
81
    if (rc != EReturnCode.OK) {
×
82
      // TODO: Handle custom frame processor configuration failure
83
      return rc;
×
84
    }
85

86
    rc = encoder.setConfig(inConfig.EncoderCfg);
×
87
    if (rc != EReturnCode.OK) {
×
88
      // TODO: Handle encoder configuration failure
89
      return rc;
×
90
    }
91

92
    rc = outputFormat.SetConfig(inConfig.OutputFormatCfg);
×
93
    if (rc != EReturnCode.OK) {
×
94
      // TODO: Handle output format configuration failure
95
      return rc;
×
96
    }
97

98
    return rc;
×
99
  }
100

101
  EReturnCode Initialize(
102
      boolean PacketLevelRemux,
103
      FilterGraph inFilterGraph,
104
      AVBufferRef HWAccelDeviceContext,
105
      AVStream inInputStream) {
106
    EReturnCode rc = EReturnCode.OK;
×
107

108
    Packet = avcodec.av_packet_alloc();
×
109
    CustomizedPacket = avcodec.av_packet_alloc();
×
110
    Frame = avutil.av_frame_alloc();
×
111
    ScaledFrame = avutil.av_frame_alloc();
×
112
    CustomizedFrame = avutil.av_frame_alloc();
×
113

114
    InputStream = inInputStream;
×
115

116
    /* We initialize this before the Encoder so we can get the Codec
117
     * parameters.
118
     */
119
    rc = OutputFormat.Initialize(InputStream);
×
120
    if (rc != EReturnCode.OK) {
×
121
      /* TODO */
122
      //                        goto end_of_function;
123
    }
124

125
    OutputStream = OutputFormat.GetStream();
×
126

127
    //                TODO:Need to find a way to add CustomPacketProcessor classes to Java
128
    //                rc = CustomPacketProcessor.Initialize();
129
    //                if(rc != OK)
130
    //                {
131
    //                        /* TODO */
132
    ////                        goto end_of_function;
133
    //                }
134

135
    if (PacketLevelRemux) {
×
136
      AVStream outputStream = OutputFormat.GetStream();
×
137
      avcodec.avcodec_parameters_copy(outputStream.codecpar(), InputStream.codecpar());
×
138
    } else {
×
139
      //                        TODO:Add Filter Graph
140
      //                        FilterGraph = inFilterGraph;
141
      //
142
      //                        snprintf(FilterBufferSinkName, sizeof(FilterBufferSinkName), "sink%d", PipelineID);
143
      //                        rc = FilterGraph.CreateBufferSink(FilterBufferSinkName, Config.FilterBufferSinkArgs,
144
      // &FilterBufferSinkContext);
145
      if (rc != EReturnCode.OK) {
×
146
        /* TODO */
147
        //                                goto end_of_function;
148
      }
149

150
      rc = Scaler.Initialize();
×
151
      if (rc != EReturnCode.OK) {
×
152
        /* TODO */
153
        //                                goto end_of_function;
154
      }
155

156
      //                        TODO:Add CustomFrameProcessor
157
      //                        rc = CustomFrameProcessor.Initialize();
158
      //                        if(rc != EReturnCode.OK)
159
      //                        {
160
      //                                /* TODO */
161
      ////                                goto end_of_function;
162
      //                        }
163

164
      rc = Encoder.initialize(OutputStream, HWAccelDeviceContext);
×
165
      if (rc != EReturnCode.OK) {
×
166
        /* TODO */
167
        //                                goto end_of_function;
168
      }
169

170
      rc = Encoder.start();
×
171
      if (rc != EReturnCode.OK) {
×
172
        /* TODO */
173
        //                                goto end_of_function;
174
      }
175
    }
176

177
    rc = OutputFormat.Start();
×
178
    if (rc != EReturnCode.OK) {
×
179
      /* TODO */
180
      //                        goto end_of_function;
181
    }
182

183
    return rc;
×
184
  }
185

186
  void SetPipelineID(int inPipelineID) {
187
    PipelineID = inPipelineID;
×
188

189
    Scaler.SetPipelineID(PipelineID);
×
190
    //          TODO:Add CustomFrameProcessor
191
    //          CustomFrameProcessor.SetPipelineID(PipelineID);
192
    Encoder.SetPipelineID(PipelineID);
×
193
    //          CustomPacketProcessor.SetPipelineID(PipelineID);
194
    OutputFormat.SetPipelineID(PipelineID);
×
195
  }
×
196

197
  EReturnCode SendFrame() {
198
    EReturnCode rc = EReturnCode.OK;
×
199

200
    if (config == null) {
×
201
      /* TODO */
202
    } else {
203
      if (MMC_EntryState.ACTIVE == config.State) {
×
204

205
        //                        rc = FilterGraph.GetFrame(FilterBufferSinkContext, Frame);
206
        //                        if(rc != OK)
207
        //                        {
208
        //                                /* TODO */
209
        ////                                goto end_of_function;
210
        //                        }
211
        while (EReturnCode.OK == rc) {
×
212
          rc = Scaler.ScaleFrame(Frame, ScaledFrame);
×
213
          if (rc != EReturnCode.OK) {
×
214
            /* TODO */
215
            //                                        goto end_of_function;
216
          }
217
          // TODO:Add CustomFrameProcessor
218
          //                                rc = CustomFrameProcessor.ProcessFrame(ScaledFrame, CustomizedFrame);
219
          if (rc != EReturnCode.OK) {
×
220
            /* TODO */
221
            //                                        goto end_of_function;
222
          }
223

224
          rc = Encoder.sendFrame(CustomizedFrame);
×
225
          if (rc != EReturnCode.OK) {
×
226
            /* TODO */
227
            //                                        goto end_of_function;
228
          }
229

230
          rc = Encoder.getNextPacket(Packet);
×
231
          while (rc == EReturnCode.OK) {
×
232
            //                                        TODO:Add CustomPacketProcessor
233
            //                                        rc = CustomPacketProcessor.ProcessPacket(Packet, CustomizedPacket);
234
            //                                        if(rc != EReturnCode.OK)
235
            //                                        {
236
            //                                                /* TODO */
237
            ////                                                goto end_of_function;
238
            //                                        }
239

240
            rc = OutputFormat.SendPacket(CustomizedPacket);
×
241
            if (rc != EReturnCode.OK) {
×
242
              /* TODO */
243
              //                                                goto end_of_function;
244
            }
245

246
            rc = Encoder.getNextPacket(Packet);
×
247
          }
248

249
          rc = FilterGraph.getFrame(FilterBufferSinkContext, Frame);
×
250
        }
251
      }
252
    }
253

254
    // end_of_function:
255

256
    return rc;
×
257
  }
258

259
  EReturnCode SendPacket(AVPacket Packet) {
260
    return OutputFormat.SendPacket(Packet);
×
261
  }
262

263
  // Placeholder for CustomFrameProcessor class
264
  static class CustomFrameProcessor {
×
265
    public EReturnCode setConfig(
266
        PipelineCfg.MMC_CustomFrameProcessorCfg_t customFrameProcessorCfg) {
267
      // TODO: Set custom frame processor configuration logic
268
      return EReturnCode.OK;
×
269
    }
270
  }
271
}
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