File Coverage

blib/lib/WWW/SVT/Play/Utils.pm
Criterion Covered Total %
statement 8 10 80.0
branch n/a
condition n/a
subroutine 3 4 75.0
pod 2 2 100.0
total 13 16 81.2


line stmt bran cond sub pod time code
1             package WWW::SVT::Play::Utils;
2              
3             # Copyright (c) 2012 - Olof Johansson
4             # All rights reserved.
5             #
6             # This program is free software; you can redistribute it and/or
7             # modify it under the same terms as Perl itself.
8              
9 1     1   6 use warnings FATAL => 'all';
  1         2  
  1         38  
10 1     1   7 use strict;
  1         3  
  1         273  
11             require Exporter;
12             our @ISA = 'Exporter';
13             our @EXPORT_OK = qw(playertype_map protocol_map);
14             our $VERSION = 0.12;
15              
16             =head1 NAME
17              
18             WWW::SVT::Play::Utils, helper functions for WWW::SVT::Play
19              
20             =head1 DESRIPTION
21              
22             This module contains some helper functions for use in other parts
23             of the WWW::SVT::Play application.
24              
25             =head1 SUBROUTINES
26              
27             =cut
28              
29             # The translation map for supported
30             my %playertype_map = (
31             'flash' => 'http',
32             'ios' => 'hls',
33             );
34             my %protocol_map = reverse %playertype_map;
35              
36             =head2 playertype_map
37              
38             Given an SVT Play internal name for a protocol (or playerType),
39             return the corresponding protocol name for it. E.g., flash gives
40             you 'hds'.
41              
42             B For the internal format "flash", it can be either HDS or
43             RTMP. You can determine this by looking at the protocol scheme
44             used by the URL. If it's RTMP, it's RTMP (duh), and if it's HTTP,
45             it's HDS. This function will return 'hds' either way.
46              
47             =cut
48              
49             sub playertype_map {
50 10     10 1 21 my $type = lc(shift);
51 10         46 return $playertype_map{$type};
52             }
53              
54             =head2 protocol_map
55              
56             Given a protocol nicename (e.g. HLS), return the SVT Play
57             internal name (for HLS, it's "ios"). That is, the opposite of
58             what playertype_map is doing.
59              
60             =cut
61              
62             sub protocol_map {
63 0     0 1   my $type = lc(shift);
64 0           return $protocol_map{$type};
65             }
66              
67             =head1 COPYRIGHT
68              
69             Copyright (c) 2012 - Olof Johansson
70             All rights reserved.
71              
72             This program is free software; you can redistribute it and/or
73             modify it under the same terms as Perl itself.
74              
75             =cut
76              
77             1;