Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
b43e57e6
Commit
b43e57e6
authored
Jul 12, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GuessType: clean up and speed up
parent
6fd538c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
39 deletions
+42
-39
src/input/item.c
src/input/item.c
+42
-39
No files found.
src/input/item.c
View file @
b43e57e6
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "item.h"
#include "item.h"
static
void
GuessType
(
input_item_t
*
p_item
);
static
int
GuessType
(
const
input_item_t
*
p_item
);
/** Stuff moved out of vlc_input.h -- FIXME: should probably not be inline
/** Stuff moved out of vlc_input.h -- FIXME: should probably not be inline
* anyway. */
* anyway. */
...
@@ -361,7 +361,7 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
...
@@ -361,7 +361,7 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
free
(
p_i
->
psz_uri
);
free
(
p_i
->
psz_uri
);
p_i
->
psz_uri
=
strdup
(
psz_uri
);
p_i
->
psz_uri
=
strdup
(
psz_uri
);
GuessType
(
p_i
);
p_i
->
i_type
=
GuessType
(
p_i
);
if
(
!
p_i
->
psz_name
&&
p_i
->
i_type
==
ITEM_TYPE_FILE
)
if
(
!
p_i
->
psz_name
&&
p_i
->
i_type
==
ITEM_TYPE_FILE
)
{
{
...
@@ -810,45 +810,48 @@ input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
...
@@ -810,45 +810,48 @@ input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
return
p_input
;
return
p_input
;
}
}
/* Guess the type of the item using the beginning of the mrl */
struct
item_type_entry
static
void
GuessType
(
input_item_t
*
p_item
)
{
{
int
i
;
const
char
psz_scheme
[
7
];
static
struct
{
const
char
*
psz_search
;
int
i_type
;
}
types_array
[]
=
uint8_t
i_type
;
{
};
{
"http"
,
ITEM_TYPE_NET
},
{
"dvd"
,
ITEM_TYPE_DISC
},
static
int
typecmp
(
const
void
*
key
,
const
void
*
entry
)
{
"cdda"
,
ITEM_TYPE_CDDA
},
{
{
"mms"
,
ITEM_TYPE_NET
},
const
struct
item_type_entry
*
type
=
entry
;
{
"rtsp"
,
ITEM_TYPE_NET
},
const
char
*
uri
=
key
,
*
scheme
=
type
->
psz_scheme
;
{
"udp"
,
ITEM_TYPE_NET
},
{
"rtp"
,
ITEM_TYPE_NET
},
return
strncmp
(
uri
,
scheme
,
strlen
(
scheme
)
);
{
"vcd"
,
ITEM_TYPE_DISC
},
}
{
"v4l"
,
ITEM_TYPE_CARD
},
{
"dshow"
,
ITEM_TYPE_CARD
},
/* Guess the type of the item using the beginning of the mrl */
{
"pvr"
,
ITEM_TYPE_CARD
},
static
int
GuessType
(
const
input_item_t
*
p_item
)
{
"dvb"
,
ITEM_TYPE_CARD
},
{
{
"qpsk"
,
ITEM_TYPE_CARD
},
static
const
struct
item_type_entry
tab
[]
=
{
"sdp"
,
ITEM_TYPE_NET
},
{
/* /!\ Alphabetical order /!\ */
{
"ftp"
,
ITEM_TYPE_NET
},
{
"cdda"
,
ITEM_TYPE_CDDA
},
{
"smb"
,
ITEM_TYPE_NET
},
{
"dshow"
,
ITEM_TYPE_CARD
},
{
NULL
,
0
}
{
"dvb"
,
ITEM_TYPE_CARD
},
{
"dvd"
,
ITEM_TYPE_DISC
},
{
"ftp"
,
ITEM_TYPE_NET
},
{
"http"
,
ITEM_TYPE_NET
},
{
"mms"
,
ITEM_TYPE_NET
},
{
"pvr"
,
ITEM_TYPE_CARD
},
{
"qpsk"
,
ITEM_TYPE_CARD
},
{
"rtp"
,
ITEM_TYPE_NET
},
{
"rtsp"
,
ITEM_TYPE_NET
},
{
"sdp"
,
ITEM_TYPE_NET
},
{
"smb"
,
ITEM_TYPE_NET
},
{
"udp"
,
ITEM_TYPE_NET
},
{
"v4l"
,
ITEM_TYPE_CARD
},
{
"vcd"
,
ITEM_TYPE_DISC
},
};
};
const
struct
item_type_entry
*
e
;
if
(
!
p_item
->
psz_uri
||
!
strstr
(
p_item
->
psz_uri
,
"://"
)
)
if
(
!
strstr
(
p_item
->
psz_uri
,
"://"
)
)
{
return
ITEM_TYPE_FILE
;
p_item
->
i_type
=
ITEM_TYPE_FILE
;
return
;
}
for
(
i
=
0
;
types_array
[
i
].
psz_search
!=
NULL
;
i
++
)
e
=
bsearch
(
p_item
->
psz_uri
,
tab
,
sizeof
(
tab
)
/
sizeof
(
tab
[
0
]
),
{
sizeof
(
tab
[
0
]
),
typecmp
);
if
(
!
strncmp
(
p_item
->
psz_uri
,
types_array
[
i
].
psz_search
,
return
e
?
e
->
i_type
:
ITEM_TYPE_FILE
;
strlen
(
types_array
[
i
].
psz_search
)
)
)
{
p_item
->
i_type
=
types_array
[
i
].
i_type
;
return
;
}
}
p_item
->
i_type
=
ITEM_TYPE_FILE
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment