Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
eaa25b09
Commit
eaa25b09
authored
Nov 03, 2017
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/tls_openssl: move some functions up in the file
Cosmetic change, reduces differences with libav.
parent
90adafe6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
73 deletions
+73
-73
tls_openssl.c
libavformat/tls_openssl.c
+73
-73
No files found.
libavformat/tls_openssl.c
View file @
eaa25b09
...
@@ -66,6 +66,79 @@ static unsigned long openssl_thread_id(void)
...
@@ -66,6 +66,79 @@ static unsigned long openssl_thread_id(void)
#endif
#endif
#endif
#endif
int
ff_openssl_init
(
void
)
{
avpriv_lock_avformat
();
if
(
!
openssl_init
)
{
SSL_library_init
();
SSL_load_error_strings
();
#if HAVE_THREADS
if
(
!
CRYPTO_get_locking_callback
())
{
int
i
;
openssl_mutexes
=
av_malloc_array
(
sizeof
(
pthread_mutex_t
),
CRYPTO_num_locks
());
if
(
!
openssl_mutexes
)
{
avpriv_unlock_avformat
();
return
AVERROR
(
ENOMEM
);
}
for
(
i
=
0
;
i
<
CRYPTO_num_locks
();
i
++
)
pthread_mutex_init
(
&
openssl_mutexes
[
i
],
NULL
);
CRYPTO_set_locking_callback
(
openssl_lock
);
#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
CRYPTO_set_id_callback
(
openssl_thread_id
);
#endif
}
#endif
}
openssl_init
++
;
avpriv_unlock_avformat
();
return
0
;
}
void
ff_openssl_deinit
(
void
)
{
avpriv_lock_avformat
();
openssl_init
--
;
if
(
!
openssl_init
)
{
#if HAVE_THREADS
if
(
CRYPTO_get_locking_callback
()
==
openssl_lock
)
{
int
i
;
CRYPTO_set_locking_callback
(
NULL
);
for
(
i
=
0
;
i
<
CRYPTO_num_locks
();
i
++
)
pthread_mutex_destroy
(
&
openssl_mutexes
[
i
]);
av_free
(
openssl_mutexes
);
}
#endif
}
avpriv_unlock_avformat
();
}
static
int
print_tls_error
(
URLContext
*
h
,
int
ret
)
{
av_log
(
h
,
AV_LOG_ERROR
,
"%s
\n
"
,
ERR_error_string
(
ERR_get_error
(),
NULL
));
return
AVERROR
(
EIO
);
}
static
int
tls_close
(
URLContext
*
h
)
{
TLSContext
*
c
=
h
->
priv_data
;
if
(
c
->
ssl
)
{
SSL_shutdown
(
c
->
ssl
);
SSL_free
(
c
->
ssl
);
}
if
(
c
->
ctx
)
SSL_CTX_free
(
c
->
ctx
);
if
(
c
->
tls_shared
.
tcp
)
ffurl_close
(
c
->
tls_shared
.
tcp
);
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
if
(
c
->
url_bio_method
)
BIO_meth_free
(
c
->
url_bio_method
);
#endif
ff_openssl_deinit
();
return
0
;
}
static
int
url_bio_create
(
BIO
*
b
)
static
int
url_bio_create
(
BIO
*
b
)
{
{
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
...
@@ -143,79 +216,6 @@ static BIO_METHOD url_bio_method = {
...
@@ -143,79 +216,6 @@ static BIO_METHOD url_bio_method = {
};
};
#endif
#endif
int
ff_openssl_init
(
void
)
{
avpriv_lock_avformat
();
if
(
!
openssl_init
)
{
SSL_library_init
();
SSL_load_error_strings
();
#if HAVE_THREADS
if
(
!
CRYPTO_get_locking_callback
())
{
int
i
;
openssl_mutexes
=
av_malloc_array
(
sizeof
(
pthread_mutex_t
),
CRYPTO_num_locks
());
if
(
!
openssl_mutexes
)
{
avpriv_unlock_avformat
();
return
AVERROR
(
ENOMEM
);
}
for
(
i
=
0
;
i
<
CRYPTO_num_locks
();
i
++
)
pthread_mutex_init
(
&
openssl_mutexes
[
i
],
NULL
);
CRYPTO_set_locking_callback
(
openssl_lock
);
#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
CRYPTO_set_id_callback
(
openssl_thread_id
);
#endif
}
#endif
}
openssl_init
++
;
avpriv_unlock_avformat
();
return
0
;
}
void
ff_openssl_deinit
(
void
)
{
avpriv_lock_avformat
();
openssl_init
--
;
if
(
!
openssl_init
)
{
#if HAVE_THREADS
if
(
CRYPTO_get_locking_callback
()
==
openssl_lock
)
{
int
i
;
CRYPTO_set_locking_callback
(
NULL
);
for
(
i
=
0
;
i
<
CRYPTO_num_locks
();
i
++
)
pthread_mutex_destroy
(
&
openssl_mutexes
[
i
]);
av_free
(
openssl_mutexes
);
}
#endif
}
avpriv_unlock_avformat
();
}
static
int
print_tls_error
(
URLContext
*
h
,
int
ret
)
{
av_log
(
h
,
AV_LOG_ERROR
,
"%s
\n
"
,
ERR_error_string
(
ERR_get_error
(),
NULL
));
return
AVERROR
(
EIO
);
}
static
int
tls_close
(
URLContext
*
h
)
{
TLSContext
*
c
=
h
->
priv_data
;
if
(
c
->
ssl
)
{
SSL_shutdown
(
c
->
ssl
);
SSL_free
(
c
->
ssl
);
}
if
(
c
->
ctx
)
SSL_CTX_free
(
c
->
ctx
);
if
(
c
->
tls_shared
.
tcp
)
ffurl_close
(
c
->
tls_shared
.
tcp
);
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
if
(
c
->
url_bio_method
)
BIO_meth_free
(
c
->
url_bio_method
);
#endif
ff_openssl_deinit
();
return
0
;
}
static
int
tls_open
(
URLContext
*
h
,
const
char
*
uri
,
int
flags
,
AVDictionary
**
options
)
static
int
tls_open
(
URLContext
*
h
,
const
char
*
uri
,
int
flags
,
AVDictionary
**
options
)
{
{
TLSContext
*
p
=
h
->
priv_data
;
TLSContext
*
p
=
h
->
priv_data
;
...
...
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