Psalm 22:16-18 NLT

I'm quite interested in knowing if David is prophesying out of his own hardship of what is to come or if he is claiming that these are happening to himself, (which I don't think is the case), or is he "prophesying" without knowing it and describing how he feels he is being treated??