@@ -324,16 +324,17 @@ - (BOOL)_startChannelPipelinesWithError:(NSError **)error {
324
324
for (VMPConfigChannelModel *channel in channels) {
325
325
NSString *type, *name;
326
326
NSDictionary <NSString *, id > *properties;
327
+ VMPPipelineManager *manager;
328
+ NSDictionary *vars = nil ;
329
+ NSString *pipeline;
327
330
328
331
type = [channel type ];
329
332
name = [channel name ];
330
333
properties = [channel properties ];
331
334
332
335
if ([type isEqualToString: VMPConfigChannelTypeV4L2]) {
333
336
VMPInfo (@" Starting channel %@ of type %@ " , name, type);
334
- NSString *device, *pipeline;
335
- NSDictionary *vars;
336
- VMPPipelineManager *manager;
337
+ NSString *device;
337
338
338
339
device = properties[@" device" ];
339
340
if (!device) {
@@ -342,29 +343,8 @@ - (BOOL)_startChannelPipelinesWithError:(NSError **)error {
342
343
}
343
344
344
345
vars = @{@" V4L2DEV" : device, @" VIDEOCHANNEL.0" : name};
345
- VMPDebug (@" Substitution dictionary for v4l2 pipeline: %@ " , vars);
346
-
347
- pipeline = [_currentProfile pipelineForChannelType: type variables: vars error: error];
348
- if (!pipeline) {
349
- return NO ;
350
- }
351
-
352
- manager = [VMPPipelineManager managerWithLaunchArgs: pipeline
353
- channel: name
354
- delegate: self ];
355
- if (![manager start ]) {
356
- CONFIG_ERROR (error, @" Failed to start V4L2 pipeline" )
357
- return NO ;
358
- }
359
-
360
- [_managedPipelines addObject: manager];
361
-
362
- VMPInfo (@" V4L2 pipeline for channel %@ started successfully" , name);
363
346
} else if ([type isEqualToString: VMPConfigChannelTypeVideoTest]) {
364
347
NSNumber *width, *height;
365
- NSString *pipeline;
366
- NSDictionary *vars;
367
- VMPPipelineManager *manager;
368
348
369
349
VMPInfo (@" Starting channel %@ of type %@ " , name, type);
370
350
width = properties[@" width" ];
@@ -380,28 +360,29 @@ - (BOOL)_startChannelPipelinesWithError:(NSError **)error {
380
360
@" WIDTH" : [width stringValue ],
381
361
@" HEIGHT" : [height stringValue ]
382
362
};
383
- VMPDebug ( @" Substitution dictionary for video test pipeline: %@ " , vars);
363
+ }
384
364
385
- // Substitute variables in pipeline template
386
- pipeline = [_currentProfile pipelineForChannelType: type variables: vars error: error];
387
- if (!pipeline) {
388
- return NO ;
389
- }
365
+ // Skip pipeline creation if type is unknown
366
+ if (nil == vars) {
367
+ continue ;
368
+ }
390
369
391
- VMPInfo (@" Creating video test pipeline manager with width %@ and height %@ " , width,
392
- height);
370
+ VMPDebug (@" Substitution dictionary for pipeline with name '%@ ': %@ " , name, vars);
393
371
394
- manager = [VMPPipelineManager managerWithLaunchArgs: pipeline
395
- channel: name
396
- delegate: self ];
397
- if (![manager start ]) {
398
- CONFIG_ERROR (error, @" Failed to start video test pipeline" )
399
- return NO ;
400
- }
401
- [_managedPipelines addObject: manager];
372
+ pipeline = [_currentProfile pipelineForChannelType: type variables: vars error: error];
373
+ if (!pipeline) {
374
+ return NO ;
375
+ }
402
376
403
- VMPInfo (@" Video test pipeline for channel %@ started successfully" , name);
377
+ manager = [VMPPipelineManager managerWithLaunchArgs: pipeline channel: name delegate: self ];
378
+ if (![manager start ]) {
379
+ CONFIG_ERROR (error, @" Failed to start pipeline" )
380
+ return NO ;
404
381
}
382
+
383
+ [_managedPipelines addObject: manager];
384
+
385
+ VMPInfo (@" pipeline '%@ ' for channel %@ started successfully" , manager, name);
405
386
}
406
387
407
388
VMPDebug (@" Finished starting channel pipelines" );
@@ -666,11 +647,11 @@ - (void)stop {
666
647
667
648
- (VMPRecordingManager *)defaultRecordingWithOptions : (NSDictionary *)options
668
649
path : (NSURL *)path
669
- deadline : (NSDate *)date
670
- error : (NSError **) error {
650
+ deadline : (NSDate *)date
651
+ error : (NSError **)error {
671
652
NSString *videoChannel = nil ;
672
653
NSString *audioChannel = nil ;
673
- NSString *pulseDevice = nil ;
654
+ NSString *pulseDevice = nil ;
674
655
NSNumber *videoBitrate = nil ;
675
656
NSNumber *audioBitrate = nil ;
676
657
NSNumber *width = nil ;
@@ -695,11 +676,12 @@ - (VMPRecordingManager *)defaultRecordingWithOptions:(NSDictionary *)options
695
676
}
696
677
697
678
if (!video || !audio) {
698
- CONFIG_ERROR (error, @" 'videoChannel' or 'audioChannel' key missing in options dictionary and not defined in channel config" );
679
+ CONFIG_ERROR (error, @" 'videoChannel' or 'audioChannel' key missing in options dictionary "
680
+ @" and not defined in channel config" );
699
681
return nil ;
700
682
}
701
683
702
- if (![[audio type ] isEqualToString: VMPConfigChannelTypePulseAudio]) {
684
+ if (![[audio type ] isEqualToString: VMPConfigChannelTypePulseAudio]) {
703
685
CONFIG_ERROR (error, @" Currently, only audio channels of type 'pulse' are supported" );
704
686
return nil ;
705
687
}
@@ -748,17 +730,17 @@ - (VMPRecordingManager *)defaultRecordingWithOptions:(NSDictionary *)options
748
730
// Substitution dictionary for video pipeline
749
731
vars = @{
750
732
@" VIDEOCHANNEL" : videoChannel,
751
- @" WIDTH" : [width stringValue ],
752
- @" HEIGHT" : [height stringValue ],
753
- @" BITRATE" : [videoBitrate stringValue ]
733
+ @" WIDTH" : [width stringValue ],
734
+ @" HEIGHT" : [height stringValue ],
735
+ @" BITRATE" : [videoBitrate stringValue ]
754
736
};
755
- template = [template stringBySubstitutingVariables: vars error: error];
737
+ template = [template stringBySubstitutingVariables: vars error: error];
756
738
if (!template) {
757
739
return nil ;
758
740
}
759
741
760
742
pipeline = [template mutableCopy ];
761
- [pipeline appendFormat: @" ! matroskamux name=mux ! filesink location=%@ " , [path path ]];
743
+ [pipeline appendFormat: @" ! matroskamux name=mux ! filesink location=%@ " , [path path ]];
762
744
763
745
template = [_currentProfile recordings ][@" pulse" ];
764
746
if (!template) {
@@ -767,17 +749,14 @@ - (VMPRecordingManager *)defaultRecordingWithOptions:(NSDictionary *)options
767
749
}
768
750
769
751
// Substitution directory for audio pipeline
770
- vars = @{
771
- @" PULSEDEV" : pulseDevice,
772
- @" BITRATE" : [audioBitrate stringValue ]
773
- };
774
- template = [template stringBySubstitutingVariables: vars error: error];
752
+ vars = @{@" PULSEDEV" : pulseDevice, @" BITRATE" : [audioBitrate stringValue ]};
753
+ template = [template stringBySubstitutingVariables: vars error: error];
775
754
if (!template) {
776
755
return nil ;
777
756
}
778
757
779
- [pipeline appendString: template];
780
- [pipeline appendString: @" ! mux." ];
758
+ [pipeline appendString: template];
759
+ [pipeline appendString: @" ! mux." ];
781
760
782
761
/* pipeline now contains a full GStreamer pipeline for encoding
783
762
and writing out a matroska file to path.
@@ -786,7 +765,10 @@ - (VMPRecordingManager *)defaultRecordingWithOptions:(NSDictionary *)options
786
765
filesink location=<PATH> <AUDIO_PIPELINE> ! mux. -e
787
766
*/
788
767
789
- return [VMPRecordingManager recorderWithLaunchArgs: pipeline path: path recordUntil: date delegate: self ];
768
+ return [VMPRecordingManager recorderWithLaunchArgs: pipeline
769
+ path: path
770
+ recordUntil: date
771
+ delegate: self ];
790
772
}
791
773
792
774
/*
0 commit comments